widestring

Definitions of: AnsiString, WideString, String, char[], char*, BSTR,

偶尔善良 提交于 2019-12-10 11:38:02
问题 This is a followup to this question AnsiString is a class, too? And string ? It is a class? And a char[] ? Can we say a WideString is a wrapper over double-byte characters, AnsiString is a wrapper over single-byte characters, and char[] is an array of single-byte characters? string not so sure what it is... Not sure about the diferent kind of string types I have in Code Builder C++ 2007 available and its portability. 回答1: AnsiString is a class provided C++ Builder, std::string is class

Should I pass a mutable reference or transfer ownership of a variable in the context of FFI?

被刻印的时光 ゝ 提交于 2019-12-08 18:52:30
I have a program that utilizes a Windows API via a C FFI (via winapi-rs). One of the functions expects a pointer to a pointer to a string as an output parameter. The function will store its result into this string. I'm using a variable of type WideCString for this string. Can I "just" pass in a mutable ref to a ref to a string into this function (inside an unsafe block) or should I rather use a functionality like .into_raw() and .from_raw() that also moves the ownership of the variable to the C function? Both versions compile and work but I'm wondering whether I'm buying any disadvantages with

Converting a wstring to jstring on Linux

荒凉一梦 提交于 2019-12-08 07:42:31
问题 I'm having problems converting a wstring to jstring in unix, as the size of wchar_t on linux in 4 bytes (not 2 bytes like windows and thus I cannot use the casting of a wchar_t to a jchar). Can anyone please help me with that? Thanks, Reza 回答1: You have to use something like iconv() , because C++ wide strings have an opaque (read: unknown) encoding, while Java expects UTF16. Try this: #include <iconv.h> #include <string> #include <vector> #include <iostream> std::u16string convert(std:

How to deal with the Unicode characters in C++

落花浮王杯 提交于 2019-12-08 03:51:12
问题 We have a commenting system built into our engine that allows programmers to put comments for various exposed variables/objects which are then used by the GUI front-end for tool-tips and help. Recently, certain tool-tips started crashing, and after much wasted time I tracked it down to the the character: ’ which, unless I am mistaken, is a unicode character and not available in ASCII. Taking this answer into consideration, I assumed wstring would fix the problem. Before making changes in the

When and why can sprintf fail?

给你一囗甜甜゛ 提交于 2019-12-05 11:55:07
I'm using swprintf to build a string into a buffer (using a loop among other things). const int MaxStringLengthPerCharacter = 10 + 1; wchar_t* pTmp = pBuffer; for ( size_t i = 0; i < nNumPlayers ; ++i) { const int nPlayerId = GetPlayer(i); const int nWritten = swprintf(pTmp, MaxStringLengthPerCharacter, TEXT("%d,"), nPlayerId); assert(nWritten >= 0 ); pTmp += nWritten; } *pTaskPlayers = '\0'; If during testing the assert never hits, can I be sure that it will never hit in live code? That is, do I need to check if nWritten < 0 and handle that, or can I safely assume that there won't be a

How do i construct a WideString with a diacratic in a non-unicode Delphi version?

烂漫一生 提交于 2019-12-01 21:32:00
问题 i am trying to construct a (test) WideString of: á (U+00E1 Small Letter Latin A with acute) but using it's decomposed form: LATIN SMALL LETTER A (U+0061) COMBINING ACUTE ACCENT (U+0301) So i have the code fragment: var test: WideString; begin test := #$0061#$0301; MessageBoxW(0, PWideChar(test), 'Character with diacratic', MB_ICONINFORMATION or MB_OK); end; Except it doesn't appear to work: This could be a bug in MessageBox, but i'm going to go ahead and say that it's more likely the bug is

cannot convert from 'const char *' to 'LPCTSTR'

半世苍凉 提交于 2019-12-01 14:52:48
I'm trying to convert string to 'LPCTSTR', but, i got following error. Error : cannot convert from 'const char *' to 'LPCTSTR' code: std::string str = "helloworld"; LPCTSTR lp = str.c_str(); Also, tried : LPCTSTR lp = (LPCTSTR)str.c_str(); But, print garbage value. Zebrafish LPCTSTR means (long pointer to constant TCHAR string). A TCHAR can either be wchar_t or char based on what your project settings are. If, in your project settings, in the "General" tab, your character set is "Use Multi-byte character set" then TCHAR is an alias for char . However, if it's set to "Use Unicode character set"

(Wide)String - storing in TFileStream, Delphi 7. What is the fastest way?

对着背影说爱祢 提交于 2019-11-30 15:37:29
问题 I'm using Delphi7 (non-unicode VCL), I need to store lots of WideStrings inside a TFileStream. I can't use TStringStream as the (wide)strings are mixed with binary data, the format is projected to speed up loading and writing the data ... However I believe that current way I'm loading/writing the strings might be a bottleneck of my code ... currently I'm writing length of a string, then writing it char by char ... while loading, first I'm loading the length, then loading char by char ... So,

(Wide)String - storing in TFileStream, Delphi 7. What is the fastest way?

假如想象 提交于 2019-11-30 14:34:11
I'm using Delphi7 (non-unicode VCL), I need to store lots of WideStrings inside a TFileStream. I can't use TStringStream as the (wide)strings are mixed with binary data, the format is projected to speed up loading and writing the data ... However I believe that current way I'm loading/writing the strings might be a bottleneck of my code ... currently I'm writing length of a string, then writing it char by char ... while loading, first I'm loading the length, then loading char by char ... So, what is the fastest way to save and load WideString to TFileStream? Thanks in advance Rob Kennedy

C++: wide characters outputting incorrectly?

跟風遠走 提交于 2019-11-30 09:34:29
My code is basically this: wstring japan = L"日本"; wstring message = L"Welcome! Japan is "; message += japan; wprintf(message.c_str()); I'm wishing to use wide strings but I do not know how they're outputted, so I used wprintf. When I run something such as: ./widestr | hexdump The hexidecimal codepoints create this: 65 57 63 6c 6d 6f 21 65 4a 20 70 61 6e 61 69 20 20 73 3f 3f e W c l m o ! e J p a n a i s ? ? Why are they all jumped in order? I mean if the wprintf is wrong I still don't get why it'd output in such a specific jumbled order! edit: endianness or something? they seem to rotate each