含义
- 其实就是编码问题
- 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
Привет, друзья!
Мы готовы предложить документы ВУЗов, расположенных в любом регионе Российской Федерации. Вы можете заказать качественно сделанный диплом за любой год, указав подходящую специальность и оценки за все дисциплины. Документы печатаются на “правильной” бумаге самого высшего качества. Это дает возможности делать настоящие дипломы, которые невозможно отличить от оригиналов. Документы заверяются необходимыми печатями и штампами.
pp-galaktika.com.ua/index.php/%D0%95%D1%81%D0%BB%D0%B8_%D0%BF%D0%BE%D1%82%D1%80%D0%B5%D0%B1%D0%BE%D0%B2%D0%B0%D0%BB%D0%B8%D1%81%D1%8C_%D0%BA%D0%BB%D0%B0%D0%BF%D0%B0%D0%BD%D0%B0,_%D0%BC%D0%B0%D0%BD%D0%BE%D0%BC%D0%B5%D1%82%D1%80%D1%8B,_%D0%B7%D0%B0%D0%B4%D0%B2%D0%B8%D0%B6%D0%BA%D0%B8_-_%D0%B6%D0%B4%D0%B5%D0%BC_%D0%92%D0%B0%D1%81!
Привет, друзья!
Мы изготавливаем дипломы любой профессии по невысоким ценам.
http://www.acrossperu.com/купить-диплом-в-коврове/
https://clomiddelivery.pro/# where can i buy clomid pills
FC Barcelona https://spain.fc-barcelona-ar.com is undoubtedly one of the most famous and well-known football clubs in the world.
buy cipro cheap: buy cipro online usa – buy cipro online without prescription
Добрый день!
Заказать документ университета можно у нас в столице.
asxdiplomik.com/kupit-diplom-specialista
buy generic ciprofloxacin: where to buy cipro online – cipro pharmacy
http://ciprodelivery.pro/# cipro pharmacy
Al-Nasr Club https://saudi.al-hilal-ar.com from Riyadh has a rich history of success, but its growth has been particularly impressive in recent years.
Добрый день!
Мы изготавливаем дипломы любых профессий по приятным тарифам.
redebrasil.app/read-blog/319_kak-vybrat-nadezhnyj-onlajn-magazin-kotoryj-prodaet-dokumenty.html?mode=day
where can i get doxycycline over the counter: how much is doxycycline cost – doxycycline cost in mexico
Al-Ittihad https://saudi.al-ittihad-ar.com is one of the most famous football clubs in Saudi Arabia. Founded in 1927, the Saudi football giant has come a long way to the pinnacle of success.
Al-Nasr https://saudi.al-nassr-ar.com is one of the most famous football teams in the Kingdom of Saudi Arabia.
Привет, друзья!
Официальная покупка диплома вуза с сокращенной программой обучения в Москве
zarabotok.forumrpg.ru/post.php?fid=26
Рады оказать помощь!
vid-st.ru vid-st.ru .
Luis Suarez https://inter-miami.luis-suarez-ar.com the famous Uruguayan footballer, ended his brilliant career in European clubs and decided to try his hand at a new challenge – Major League Soccer.
http://doxycyclinedelivery.pro/# can you buy doxycycline
лучшие порно видео лучшие порно видео .
https://amoxildelivery.pro/# amoxicillin canada price
скачать порно коллекций http://www.porn-library.ru .
Добрый день!
Приобрести диплом ВУЗа.
islider.ru/read-blog/564
ножничный грузовой подъемник нужен подъемник грузовой
Здравствуйте!
Где и как купить диплом о высшем образовании без лишних рисков
jordirocas.com/node/3383
Окажем помощь!.
amoxicillin 500 mg capsule: price for amoxicillin 875 mg – amoxicillin 50 mg tablets
Здравствуйте!
Заказать документ университета можно в нашем сервисе.
asxdiplomik24.ru/kupit-diplom-moskva
Успешной учебы!
Bayern Munich’s https://bayern.jamal-musiala-ar.com young midfielder, Jamal Musiala, has become one of the brightest talents in European football.
Здравствуйте!
Сколько стоит диплом высшего и среднего образования и как его получить?
newsbig.fotosdefrases.com/rekomendacii-po-priobreteniu-dokumenta-v-internete
Привет, друзья!
Приобрести диплом о высшем образовании.
http://www.eruptz.com/read-blog/3333_kak-kupit-nedorogo-kachestvennyj-diplom-v-seti.html
generic doxycycline 200 mg: doxycycline 150 mg tablets – doxycycline canada brand name
http://doxycyclinedelivery.pro/# 80 mg doxycycline
Arsenal https://arsenal.mesut-ozil-ar.com made a high-profile signing in 2013, signing star midfielder Mesut Ozil from Real Madrid.
https://euroavia24.com – Cheap flights, hotels and transfers around the world!
The Saudi Football League https://saudi-arabian-championship.saudi-pro-league-ar.com known as the Saudi Professional League, is one of the most competitive and dynamic leagues in the world.
Rodrigo Goes https://real-madrid.rodrygo-ar.com better known as Rodrigo, is one of the brightest young talents in modern football.
In an era when many young footballers struggle to find their place at elite clubs, Javi’s https://barcelona.gavi-ar.com story at Barcelona stands out as an exceptional one.
http://paxloviddelivery.pro/# Paxlovid buy online
Paxlovid buy online: Paxlovid buy online – Paxlovid buy online
buy ciprofloxacin over the counter: ciprofloxacin generic price – ciprofloxacin over the counter
amoxicillin online pharmacy: 875 mg amoxicillin cost – where can you get amoxicillin
https://clomiddelivery.pro/# can you buy generic clomid without insurance
Добрый день!
Мы предлагаем документы техникумов, которые расположены в любом регионе России. Можно купить качественный диплом за любой год, в том числе документы СССР. Документы печатаются на “правильной” бумаге самого высокого качества. Это дает возможности делать настоящие дипломы, которые невозможно отличить от оригинала. Документы будут заверены всеми требуемыми печатями и штампами.
f0npknzlq.win-blog.com/8155025/%D0%9A%D0%B0%D0%BA-%D0%B2%D0%BE%D0%B7%D0%BC%D0%BE%D0%B6%D0%BD%D0%BE-%D0%B1%D1%83%D0%B4%D0%B5%D1%82-%D0%BD%D0%B5%D0%B4%D0%BE%D1%80%D0%BE%D0%B3%D0%BE-%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C-%D0%B0%D1%82%D1%82%D0%B5%D1%81%D1%82%D0%B0%D1%82-%D0%B2-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BD%D0%B5%D1%82-%D0%BC%D0%B0%D0%B3%D0%B0%D0%B7%D0%B8%D0%BD%D0%B5
In recent years, the leading positions in the Spanish https://spanish-championship.laliga-ar.com championship have been firmly occupied by two major giants – Barcelona and Real Madrid.
In the German football https://german-championship.bundesliga-football-ar.com championship known as the Bundesliga, rivalries between clubs have always been intense.
The Italian football championship https://italian-championship.serie-a-ar.com known as Serie A, has seen an impressive revival in recent years.
The road to the Premier League https://english-championship.premier-league-ar.com begins long before a team gets promoted to the English Premier League for the first time
The golf https://arabic.golfclub-ar.com industry in the Arab world is growing rapidly, attracting players from all over the world.
самое классное порево https://klassny-sex.ru .
https://ciprodelivery.pro/# buy cipro online canada
Привет!
Легальные способы покупки диплома о среднем полном образовании
landik-diploms-srednee.ru/kupit-diplom-volgograd В
Привет, друзья!
Заказать документ института
ast-diplomas24.ru/kupit-diplom-o-srednem-obrazovanii