![](/img/trans.png)
[英]Strange behavior (anonymous namespace with swscanf)
我有下一個實驗代碼。 該代碼因標記行上的分段錯誤而失敗。 如果我從匿名命名空間中取出 str2MxfKey function 或為命名空間命名,代碼將毫無問題地運行。 這種奇怪的行為只在發布版本上重現。 有人可以向我解釋該問題的根本原因嗎? Ubuntu 22.04, cmake 3.22.1, ...
[英]Strange behavior (anonymous namespace with swscanf)
我有下一個實驗代碼。 該代碼因標記行上的分段錯誤而失敗。 如果我從匿名命名空間中取出 str2MxfKey function 或為命名空間命名,代碼將毫無問題地運行。 這種奇怪的行為只在發布版本上重現。 有人可以向我解釋該問題的根本原因嗎? Ubuntu 22.04, cmake 3.22.1, ...
[英]Is there anything else needed to format BSTR wrapper to wstring using fmt?
該項目有一個為BSTR編寫的包裝器。 默認情況下使用WinString類型會出現以下錯誤。 error C2338: Cannot format an argument. To make type T formattable provide a formatter<T> special ...
[英]Do c++ string objects handle variable width UTF encodings?
我讀過的參考資料根本不清楚。 假設我正在使用 std::wstring object my_string 如果我指的是 my_string[23] 處的“字符”,那實際上是字符串中的第 23 個 UTF-16 代碼點嗎? 或者它只是在偏移量 23*2 字節處的任何數據,即使某些代碼點位於擴展平面中 ...
[英]C++ issue with conversion of std::string to std::wstring - Windows vs Linux
我正在嘗試使用將字符串"pokémon"從 std::string 轉換為 std::wstring std::wstring wsTmp(str.begin(), str.end()); 這適用於 Windows,但在 Linux 上它返回"pok\xffffffc3\xffffffa9mon ...
[英]How to pass wide characters to libcurl API which takes only const char*?
我正在使用libcurl將一些文件上傳到我的服務器。 我需要處理名稱使用不同語言的文件,例如中文、印地語等。為此,我需要使用std::wstring而不是std::string來處理文件。 libcurl有一個函數,其原型如下: 但我不能通過std::wstring::c_str()因為它會 ...
[英]C++17 UTF8 std::string to std::wstring UTF32 using unicode.org code or C++ standard functions?
在穩定且經過測試的系統中尋找經典 UTF8 到 UTF32 的工作解決方案。 現在我有了 Unicode.org 的來源 C 代碼: https: //android.googlesource.com/platform/external/id3lib/+/master/unicode.org/Co ...
[英]How to convert extended ascii characters from char to wstring in c++
我使用 ifstream 的讀取方法將文件讀取到 char* memory 塊中。 我對 memory 塊中的每個字符調用我的 GetChar 方法以寫入 wstring。 我正在嘗試將 unicode 個字符寫入屏幕(至少我認為它們是 unicode,如果我錯了請糾正我 - 哦不,看起來我錯了它 ...
[英]Convert from std::wstring to std::string
我正在將 wstring 轉換為帶有 std::codecvt_utf8 的字符串,如this question中所述,但是當我嘗試希臘或中文字母符號已損壞時,我可以在調試 Locals window 中看到它,例如日本變成“日斬 " 我究竟做錯了什么? ...
[英]What is mbstate_t and why to reset it?
您能否向我解釋一下mbstate_t到底是什么? 我已經閱讀了cppreference 描述,但我仍然不明白它的用途。 我所理解的是mbstate_t是一些 static 結構,對於mbtowc() 、 wctomb()等有限的功能集是可見的,但我仍然對如何使用它感到困惑。 我可以在 cppref ...
[英]What is a suitable compression algorithm for a large set of UTF-16 strings(multilingual)?
我需要壓縮大量短的多語言字符串(每個<1000 字節)。 我曾嘗試為每種語言使用單獨的字典來實現 LZW。 有沒有更好的解決方案? 字符串存儲在一個集合中,因此順序無關緊要。 ...
[英]MFC(unicode): how do i convert a wstring filepath to a string path?
我有一個使用 MFC、C++ 創建並使用 Unicode 的應用程序。 我必須使用 wstring 文件路徑加載紋理。 這個 wstring 文件路徑是由系統給出的,我不需要在任何地方顯示它。 我只需要將它傳遞給紋理加載方法。 不幸的是,紋理加載方法(來自 lib)只采用字符串 filePath。 ...
[英]010 Editor template: convert a int to wchar_t
我正在以這種方式從 010 模板中的二進制文件中讀取單個wchar_t字符 wchar_t character; 它會給我例如@的64 ,之后我需要將0x20添加到64,所以現在應該是96 我的問題是如何在 010 模板中再次add操作后的輸出轉換為 wchar_t(或字符串)? ...
[英]swscanf implementation in casting
我正在處理一個項目,在該項目中我需要使用swscanf()來確定字符串值是十進制還是十六進制。 之后,我將該值放入一個變量中。 function 是: StringFormat是一個用於格式檢查的枚舉。 我想為案例創建swscanf()的替代方案。 有什么辦法可以做到這一點? ...
[英]How to skip/disregard files with names that use wide characters using std::filesystem?
我正在遍歷一大組嵌套目錄,搜索某些擴展名的文件,例如“.foo”,使用如下代碼: namespace fs = std::filesystem; int main(int argc, char* argv[]) { std::ios_base::sync_with_stdio(false) ...
[英]Bug in gcc wstring_convert?
我使用 MinGW 8.1.0 64 位。 此代碼片段: #include <clocale> #if __has_include(<codecvt>) #include <codecvt> #endif #include <cstdlib> #inc ...
[英]Error : 'to_wstring' is not a member of 'std'
我不知道為什么這不編譯。 編譯器:gcc 5.1.0 IDE:代碼塊 17.12 ...
[英]How to use wstring find/replace for a case insensitve replacement?
這段代碼非常適合字符串替換,但它區分大小寫,這就是我需要的:WCHAR *StringReplaceEx(CONST WCHAR *orig, CONST WCHAR * pattern, CONST WCHAR *repl, WCHAR *sOut) { wstring wsorigi ...
[英]C++ SSO : How to programatically find if a std::wstring is allocated with Short String Optimization?
如何以編程方式查找std::wstring是否分配有Short String Optimization ? 我試圖檢測此類情況並使用reserve來退出 SSO。 下面的代碼在地址上打印了一個小的差異: Output 示例: 盡管在 windows 控制台應用程序中,地址完全相同: ...
[英]std::wstring::find() broken in g++?
這個程序有什么問題: 如果沒有問題,Valgrind 為什么會抱怨: 請注意,當我將字符串的大小減少一個字符時: 或者當我搜索字符串中的字符時: 或者當我使用std::string而不是std::wstring時: 然后 Valgrind 沒有抱怨。 我的環境: ...
[英]How is const std::wstring encoded and how to change to UTF-16
我創建了這個最小的工作 C++ 示例片段,以在定義一個帶有德國非 ASCII 字符的字符串時,比較std::string和std::wstring字節(通過它們的十六進制表示)。 #include <iostream> #include <iomanip> #include ...