含义
- 其实就是编码问题
- 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
medicine in mexico pharmacies: purple pharmacy mexico price list – mexican mail order pharmacies
legit canadian pharmacy canada drugs online canadian pharmacy price checker
canadapharmacyonline: canadian mail order pharmacy – pharmacy canadian
pharmacy canadian superstore reputable canadian pharmacy my canadian pharmacy reviews
Online medicine home delivery: indian pharmacy – top 10 pharmacies in india
заказать дипломную заказать дипломную .
купить диплом архитектора ast-diploms.com .
canadian pharmacy online: medication canadian pharmacy – canadian pharmacy meds
http://canadapharmast.com/# best mail order pharmacy canada
top 10 pharmacies in india: mail order pharmacy india – pharmacy website india
Sadio Mane https://al-nassr.sadio-mane-ar.com the Senegalese footballer best known for his performances at clubs such as Southampton and Liverpool, has become a prominent figure in Al Nassr.
Brazilian footballer Ricardo Escarson https://orlando-city.kaka-ar.com dos Santos Leite, better known as Kaka, is one of the most famous and successful players in football history.
Bella Hadid https://img-models.bella-hadid-ar.com is an American model who has emerged in recent years as one of the most influential figures in the world of fashion.
canadian pharmacy oxycodone canadian pharmacy king best online canadian pharmacy
п»їbest mexican online pharmacies: mexican border pharmacies shipping to usa – buying prescription drugs in mexico online
medicine in mexico pharmacies: mexican pharmaceuticals online – mexico pharmacy
legitimate canadian pharmacies: canada drugs online – canadapharmacyonline legit
world pharmacy india: indian pharmacy online – indian pharmacy
pharmacy rx world canada prescription drugs canada buy online pharmacy rx world canada
Полезные советы по безопасной покупке диплома о высшем образовании
ast-diplomas24.ru/kupit-diplom-sankt-peterburg
top online pharmacy india Online medicine order buy medicines online in india
https://canadapharmast.online/# canadian family pharmacy
mail order pharmacy india: indianpharmacy com – top 10 pharmacies in india
https://canadapharmast.online/# prescription drugs canada buy online
trusted canadian pharmacy: vipps approved canadian online pharmacy – canadianpharmacy com
medicine in mexico pharmacies: mexican mail order pharmacies – mexican mail order pharmacies
http://canadapharmast.com/# pharmacies in canada that ship to the us
п»їlegitimate online pharmacies india world pharmacy india п»їlegitimate online pharmacies india
mexican rx online: п»їbest mexican online pharmacies – mexican pharmaceuticals online
best canadian pharmacy to buy from: canadian pharmacy 24 – canadian pharmacy 365
Здравствуйте!
Как не попасть впросак при покупке диплома колледжа или ПТУ в России
http://www.tdp74.ru/forum/user/5416
Будем рады вам помочь!.
п»їlegitimate online pharmacies india: Online medicine order – buy medicines online in india
canadian pharmacy cheap: prescription drugs canada buy online – reputable canadian online pharmacies
Привет, друзья!
Мы можем предложить документы техникумов, которые находятся на территории всей Российской Федерации. Можно купить качественно напечатанный диплом от любого учебного заведения, за любой год, включая сюда документы старого образца СССР. Документы выпускаются на бумаге самого высокого качества. Это позволяет делать государственные дипломы, которые не отличить от оригинала. Документы заверяются необходимыми печатями и подписями.
textualheritage.org/index.php?option=com_content&task=view&id=1081
https://foruspharma.com/# mexico pharmacies prescription drugs
Здравствуйте!
Купить документ института вы имеете возможность в нашей компании в столице.
ast-diplomas24.ru/kupit-diplom-nizhnij-novgorod
Хорошей учебы!
Привет!
Заказать документ о получении высшего образования можно в нашем сервисе.
ast-diplomas.com/kupit-diplom-magistra
Привет, друзья!
Предлагаем документы техникумов, которые находятся на территории всей России. Можно приобрести качественно напечатанный диплом за любой год, указав подходящую специальность и хорошие оценки за все дисциплины. Документы печатаются на бумаге высшего качества. Это позволяет делать настоящие дипломы, которые невозможно отличить от оригинала. Документы заверяются необходимыми печатями и штампами.
Мы можем предложить дипломы любой профессии по приятным ценам. Стоимость может зависеть от выбранной специальности, года выпуска и ВУЗа. Всегда стараемся поддерживать для покупателей адекватную политику цен. Важно, чтобы документы были доступными для большого количества граждан.
arusak-diploms-srednee.ru/kupit-diplom-v-krasnoiarske
Успехов в учебе!
Привет!
Мы предлагаем дипломы любой профессии по приятным ценам.
poobshchaemsya.ru/gallery/image/kakie-magaziny-s-diplomami-na-tekuschiy-den-imeyutsya-356/
Kylie Jenner https://kylie-cosmetics.kylie-jenner-ar.com is an American model, media personality, and businesswoman, born on August 10, 1997 in Los Angeles, California.
Продажа новых автомобилей Hongqi
https://hongqi-krasnoyarsk.ru/owners в Красноярске у официального дилера Хончи. Весь модельный ряд, все комплектации, выгодные цены, кредит, лизинг, трейд-ин
Upcoming fantasy MOBA https://bladesofthevoid.com evolved by Web3. Gacha perks, AI and crafting in one swirling solution!
Казахский национальный технический университет https://satbayev.university им. К.Сатпаева
Football in Saudi Arabia https://al-hilal.saud-abdulhamid-ar.com is gaining more and more popularity and recognition on the international stage, and Saud Abdul Hamid, the young and talented defender of Al Hilal, is a shining example of this success.
Khvicha Kvaratskhelia https://napoli.khvicha-kvaratskhelia-ar.com is a name that in recent years has become a symbol of Georgian football talent and ambition.
Angel Di Maria https://benfica.angel-di-maria-ar.com is a name that will forever remain in the memories of Benfica fans.
Roberto Firmino https://al-ahli.roberto-firmino-ar.com one of the most talented and famous Brazilian footballers of our time, has paved his way to success in different leagues and teams.
Maria Sharapova https://tennis.maria-sharapova-ar.com was born on April 19, 1987 in Nyagan, Russia. When Masha was 7 years old, her family moved to Florida, where she started playing tennis.
Muhammad Al Owais https://al-hilal.mohammed-alowais-ar.com is one of the most prominent names in modern Saudi football. His path to success in Al Hilal team became an example for many young athletes.
Luis Diaz https://liverpool.luis-diaz-ar.com is a young Colombian striker who has enjoyed rapid growth since joining the ” Liverpool” in January 2022.