草庐IT

fshort-wchar

全部标签

c++ - MacOS clang 通过 Homebrew 在 Mojave `wchar.h` 下损坏

这个问题在这里已经有了答案:'wchar.h'filenotfound(9个回答)关闭去年。毫不奇怪,OSXMojave的新更新破坏了我在Homebrew中的llvm安装,这些是我尝试的步骤:xcode-select--install#Complained,soIinstalledcommandLineToolsfromherehttps://developer.apple.com/download/more/xcode-select-p/Library/Developer/CommandLineToolsxcode-select--install#Nowsaysinstalledsu

c++ - 在不使用构造函数的情况下将 WCHAR* 转换为 wstring

我有一个wchar数组,我需要使用winapi函数将数据写入其中,我想在std::wstring中获取它,我知道std::wstringt(wText);有效,但我不能在if语句中声明它,因为它不会存在于该范围之外。我也不能以这种方式调用构造函数:WCHARwText[256];std::wstringt=L"";if(somecondition){t=t(wText);}我能做什么?当不满足条件时,我希望wstring等于"",当条件满足时,我想将一个WCHAR数组放入其中。 最佳答案 您可以通过在表达式中调用构造函数来构造一个临

c++ - 无法在 MFC/C++ 项目中将参数 1 从 'const wchar_t *' 转换为 'LPCTSTR'

我在线上遇到编译错误:MessageBox(e.getAllExceptionStr().c_str(),_T("Errorinitializingthesoundplayer"));Error4errorC2664:'CWnd::MessageBoxA':cannotconvertparameter1from'constwchar_t*'to'LPCTSTR'c:\users\daniel\documents\visualstudio2012\projects\mytest1\mytest1\main1.cpp1411MyTest1我不知道如何解决这个错误,我尝试了以下方法:Mess

c++ - boost::filesystem::path::native() 返回 std::basic_string<wchar_t> 而不是 std::basic_string<char>

尽管以下代码可以在Linux上编译,但我无法在Windows上编译它:boost::filesystem::pathdefaultSaveFilePath(base_directory);defaultSaveFilePath=defaultSaveFilePath/"defaultfile.name";conststd::strings=defaultSaveFilePath.native();returnsave(s);其中base_directory是一个类的属性,它的类型是std::string,而函数save只需要一个conststd::string&作为参数。编译器提示第三

c++ - 如何在 iOS 中将 UTF-8 字符串转换为 wchars?

我有一个需要移植到iOS的Win32函数://LoadsUTF-8fileandconvertstoaUTF-16stringboolLoadUTF8File(charconst*filename,wstring&str){size_tsize;boolrc=false;void*bytes=LoadFile(filename,&size);if(bytes!=0){intlen=MultiByteToWideChar(CP_UTF8,0,(LPCCH)bytes,size,0,0);if(len>0){str.resize(len+1);MultiByteToWideChar(CP_

android - Android真的没有wchar_t吗?

我构建了一个如下所示的简单方法wchar_tbuf[1024]={};voidlogDebugInfo(wchar_t*fmt,...){va_listargs;va_start(args,fmt);vswprintf(buf,sizeof(buf),fmt,args);va_end(args);}jstringJava_com_example_hellojni_HelloJni_stringFromJNI(JNIEnv*env,jobjectthiz){logDebugInfo(L"test%s,%d..",L"integer",10);return(*env)->NewString

c++ - 16 位 wchar_t 是否正式代表完整的 Unicode?

在¹comp.lang.c++Usenet组中,我最近断言,基于我所知道的,Windows的16位wchar_t,使用UTF-16编码,其中有时有两个这样的值(称为“代理对”)对于单个Unicode代码点是必需的,对于表示Unicode是无效的。虽然Unicode联盟2004年的技术说明12为使用用于内部处理的UTF-16,以及一系列令人印象深刻的软件。显然,最初的意图似乎是每个代码点有一个wchar_t值,这与C和C++标准库的假设一致。例如。在³unix.org的网页“ISOC修正案1(MSE)”中,关于在1995年将wchar_t纳入C标准的修正案,作者认为”Theprimary

c++ - 冲突 : definition of wchar_t string in C++ standard and Windows implementation?

Fromc++20032.13Awidestringliteralhastype“arrayofnconstwchar_t”andhasstaticstorageduration,wherenisthesizeofthestringasdefinedbelowThesizeofawidestringliteralisthetotalnumberofescapesequences,universal-character-names,andothercharacters,plusonefortheterminatingL’\0’.Fromc++0x2.14.5Awidestringlite

c# - 如何将 wchar_t* 从 C++ 编码到 C# 作为输出参数或返回值?

我试过很多方法,但没有一个奏效。有人对此有正确的例子吗?我只想将wchar_t*值从函数移动到C#级别。 最佳答案 这并不像您想象的那么难……wchar_t*是什么?该类型通常代表什么值?一个字符串。它等同于windows.h中定义的LPWSTR类型。因此,您将其编码为string类型。但是,由于它是一个out参数(或返回值),您需要使用StringBuilderclass在C#端,而不是string类型。P/Invoke语法看起来像这样:[DllImport("MyLib.dll")]publicstaticexternvoidM

c++ - wchar_t 数据是否需要字节序转换?

在C/C++中,如果一个多字节宽字符(wchar_t)值从大端系统传输到小端系统(反之亦然),它是否会在另一个系统上产生相同的值边?还是需要交换字节? 最佳答案 是的,你需要交换它们。字节将按照它们被放入的相同顺序从传输中检索。只是在另一端,这些字节的顺序具有不同的含义。因此,您需要将它们转换为正确的字节序(这是一个词吗?)。行之有效的方法是在传输之前转换为网络字节顺序。然后在收到时转换回主机特定的字节顺序(从网络字节顺序)。一组帮助字节序转换的函数:ntohsConverta16-bitquantityfromnetworkbyt