含义
- 其实就是编码问题
- A:
- 代表ANSI
- W:
- 代表宽字节(wide),即 Unicode
- A:
- 一般win的库函数如果后面不加 ’A‘ 或 'W' 时,直接给它传字符串类型值时会报错:
- 以我常用的 ShellExecute() 为例:
- 会报错:
- "const char *" 类型的实参与 "LPCWSTR" 类型的形参不兼容
- 不存在从 “std::string” 到 “LPCWSTR” 的适当转换函数
- LPCWSTR 是个啥?让我们来看看它的定义:
- typedef const wchar_t* LPCWSTR;
- 即指向unicode编码字符串的32位指针,并且所指向字符串是wchar,而非char。
- 解决方法:
- 把函数改为 ShellExecuteA() 或 ShellExecuteW()
- 或者在传字符串时使用宏定义转换类型
- 对于常量字符串:
- _T() (推荐使用)自适应转换,当程序定义为unicode时,相当于L,当程序定义为ansi时,则被忽略(头文件:#include <tchar.h>)
- L ;例如原本传值为 fun("open"),使用后为fun(L"open");注意这个L并没有括号。
- CA2W() 从宽字符集(Unicode)转为多字符集(ANSI)(头文件:#include <atlstr.h>)
- CW2A() 从多字符集(ANSI)转化为宽字符集(Unicode)(头文件:#include <atlstr.h>)
- 对于string / char[] / const char[] :
- 使用以下函数
LPCWSTR stringToLPCWSTR(const std::string& orig)
{
size_t origsize = orig.length() + 1;
const size_t newsize = 100;
size_t convertedChars = 0;
wchar_t *wcstring = (wchar_t *)malloc(sizeof(wchar_t)*(orig.length()-1));
mbstowcs_s(&convertedChars, wcstring, origsize, orig.c_str(), _TRUNCATE);
return wcstring;
}
- -
- -
- 那么如果我是 char[] 或者 const char[] 呢?那当然是转string再使用上面的函数啦。
- 示例:
- -
ShellExecuteA(NULL, "open", "https://blog.coolight.cool/", NULL, NULL, SW_SHOWNORMAL);
string str = "https://blog.coolight.cool/";
ShellExecute(NULL, _T("open"), stringToLPCWSTR(str), NULL, NULL, SW_SHOWNORMAL);
const char link_char[] = "https://blog.coolight.cool/";
ShellExecute(NULL, _T("open"), stringToLPCWSTR(string(link_char)), NULL, NULL, SW_SHOWNORMAL);
ShellExecute(NULL, L"open", CA2W("https://blog.coolight.cool/"), NULL, NULL, SW_SHOWNORMAL);
常见编码格式
见另一篇文章:常见编码格式 / 字节序(大端 / 小端)/ 带BOM
Добрый день!
Полезные советы по безопасной покупке диплома о высшем образовании
all-smeta.ru/?sid=0e06dd097aaff7962ef8ae8c885ef815
Рады помочь!
http://doxycyclinedelivery.pro/# doxycycline 100mg best price
amoxicillin online canada: buy amoxicillin online with paypal – buy amoxicillin 500mg capsules uk
Добрый день!
Купить диплом любого ВУЗа.
c904581v.beget.tech/2024/07/04/kak-podobrat-nadezhnyy-internet-magazin-s-shirokim-vyborom-diplomov.html
buy cipro: ciprofloxacin over the counter – ciprofloxacin mail online
Привет!
Приобрести документ о получении высшего образования можно у нас в Москве.
ast-diplom.com/kupit-diplom-sankt-peterburg
Хорошей учебы!
https://ciprodelivery.pro/# buy cipro online
Привет!
Где купить диплом специалиста?
http://www.dizalty.com/read-blog/67606
Привет!
Приобрести документ о получении высшего образования можно у нас.
asxdiplomik.com/kupit-diplom-bakalavra-ili-specialista
http://clomiddelivery.pro/# can i get generic clomid without rx
купить дипломы о высшем образовании цена люкс diploms-x.com .
Manny Pacquiao https://filipino-boxer.manny-pacquiao-ar.com is one of the most prominent boxers in the history of the sport.
ciprofloxacin 500 mg tablet price: antibiotics cipro – antibiotics cipro
Muhammad Ali https://american-boxer.muhammad-ali-ar.com is perhaps one of the most famous and greatest athletes in the history of boxing.
Mike Tyson https://american-boxer.mike-tyson-ar.com one of the most famous and influential boxers in history, was born on June 30, 1966 in Brooklyn, New York.
doxycycline online without prescription: doxycycline 50mg – doxycycline tablets 100mg
enterprise car rental Montenegro https://montenegro-car-rental-hire.com
http://ciprodelivery.pro/# cipro ciprofloxacin
doxycycline capsules 50mg 100mg: doxycycline in usa – pharmacy prices for doxycycline
Добрый день!
Мы изготавливаем дипломы любой профессии по выгодным ценам.
http://www.greendoorkitchen.com/2024/06/25/диплом-университета-купил/
Добрый день!
Где заказать диплом специалиста?
Заказать диплом о высшем образовании.
lolipopnews.ru/kupite-diplom-i-zabudte-o-studencheskih-dolgih-nochah
Добрый день!
Мы предлагаем документы техникумов, расположенных на территории всей РФ. Вы имеете возможность купить качественный диплом за любой год, включая сюда документы старого образца. Дипломы и аттестаты делаются на “правильной” бумаге высшего качества. Это позволяет делать настоящие дипломы, которые не отличить от оригинала. Они будут заверены необходимыми печатями и подписями.
secure.smore.com/n/x031d-russian-diplom
https://amoxildelivery.pro/# amoxicillin 500mg capsules price
купить техникум купить техникум .
Michael Jordan https://chicago-bulls.michael-jordan-ar.com is one of the greatest basketball players of all time, whose career with the Chicago Bulls is legendary.
дизайн интерьера торрент https://dizayn-interera-doma.ru
купить диплом о среднем образовании в липецке ast-diploms.com .
Привет, друзья!
Заказать диплом любого университета.
ros.listbb.ru/viewtopic.php?f=2&t=523
Хорошей учебы!
The Formula One World Championship https://world-circuit-racing-championship.formula-1-ar.com, known as the Formula Championship in motor racing, is the highest tier of professional motor racing.
After some difficult years in the late 2010s, Manchester United https://england.manchester-united-ar.com returned to greatness in English football by 2024.
http://doxycyclinedelivery.pro/# doxycycline 250 mg
clomid generic: can you get generic clomid without rx – can you buy cheap clomid for sale
Привет!
Всё, что нужно знать о покупке аттестата о среднем образовании без рисков.
Приобрести диплом любого университета.
beinsadouno.bg/events/event/46-%D0%BF%D0%BE%D0%BA%D1%83%D0%BF%D0%B0%D0%B5%D0%BC-%D0%B4%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D1%8B-%D0%B2-%D0%BF%D1%80%D0%BE%D0%B2%D0%B5%D1%80%D0%B5%D0%BD%D0%BD%D0%BE%D0%BC-%D0%BE%D0%BD%D0%BB%D0%B0%D0%B9%D0%BD-%D0%BC%D0%B0%D0%B3%D0%B0%D0%B7%D0%B8%D0%BD%D0%B5-%D0%BF%D0%BE-%D0%B2%D1%8B%D0%B3%D0%BE%D0%B4%D0%BD%D0%BE%D0%B9-%D1%86%D0%B5%D0%BD%D0%B5/
Здравствуйте!
Легальная покупка диплома ВУЗа с сокращенной программой обучения
opengadjet.ru/legkiy-sposob-poluchit-diplom-byistro-i-prosto
Всегда вам поможем!
https://paxloviddelivery.pro/# paxlovid cost without insurance
buy cipro online without prescription: ciprofloxacin – cipro pharmacy
Jennifer Lopez https://lets-get-loud.jenniferlopez-ar.com was born in 1969 in the Bronx, New York, to parents who were Puerto Rican immigrants.
http://doxycyclinedelivery.pro/# doxycycline 40 mg generic cost
лучшее порево бесплатно лучшее порево бесплатно .
When Taylor Swift https://shake-it-off.taylor-swift-ar.com released “Shake It Off” in 2014, she had no idea how much the song would impact her life and music career.
Привет!
Приобрести документ института можно в нашей компании в столице.
diplomyx24.ru/otzyvy
Успешной учебы!
Priyanka Chopra https://baywatch.priyankachopra-ar.com is an Indian actress, singer, film producer and model who has achieved global success.
Liverpool https://england.liverpool-ar.com holds a special place in the history of football in England.
Автомобили Hongqi https://hongqi-krasnoyarsk.ru в наличии – официальный дилер Hongqi Красноярск
Привет!
Где заказать диплом по актуальной специальности?
Заказать диплом любого университета.
chrstms.ru/club/user/11503/blog/11039/
https://amoxildelivery.pro/# amoxicillin 250 mg
Покупка диплома о среднем полном образовании: как избежать мошенничества?
ast-diplom.com/kupit-diplom-rostov-na-donu
buy generic ciprofloxacin: cipro for sale – where to buy cipro online
Здравствуйте!
Купить документ о получении высшего образования можно у нас в столице.
ast-diploms.com/kupit-diplom-omsk
80 mg doxycycline: buy doxycycline 500mg – doxycycline 100mg cost australia