Questions tagged [widestring]

112 questions
5
votes
4 answers

Why doesn't wstring::c_str cause a memory leak if not properly deleted

Code Segment 1: wchar_t *aString() { wchar_t *str = new wchar[5]; wcscpy(str, "asdf\0"); return str; } wchar_t *value1 = aString(); Code Segment 2 wstring wstr = L"a value"; wchar_t *value = wstr.c_str(); If value from code segment…
monksy
  • 14,156
  • 17
  • 75
  • 124
5
votes
4 answers

2-byte (UCS-2) wide strings under GCC

when porting my Visual C++ project to GCC, I found out that the wchar_t datatype is 4-byte UTF-32 by default. I could override that with a compiler option, but then the whole wcs* (wcslen, wcscmp, etc.) part of RTL is rendered unusable, since it…
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
5
votes
2 answers

Appending UnicodeString to WideString in Delphi

I'm curious about what happens with this piece of code in Delphi 2010: function foo: WideString; var myUnicodeString: UnicodeString; begin for i:=1 to 1000 do begin myUnicodeString := ... something ...; result := result +…
Roddy
  • 66,617
  • 42
  • 165
  • 277
4
votes
3 answers

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

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:…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
4
votes
2 answers

Combining wide string literal with string macro

I have a macro for a character string as follows: #define APPNAME "MyApp" Now I want to construct a wide string using this macro by doing something like: const wchar_t *AppProgID = APPNAME L".Document"; However, this generates a "concatenating…
flashk
  • 2,451
  • 2
  • 20
  • 31
4
votes
1 answer

c# : how to convert c# string to c++ wstring and vice-versa

c# code- string s="おはよう"; I want to send s to c++ dll, as wstring.. how to convert string to wstring in c# ?
Amit
  • 219
  • 2
  • 7
  • 14
4
votes
3 answers

How to access characters of a WideString by index?

i have the following code snippit that won't compile: procedure Frob(const Grob: WideString); var s: WideString; begin s := Grob[7]+Grob[8]+Grob[5]+Grob[6]+Grob[3]+Grob[4]+Grob[1]+Grob[2]; ... end; Delphi5 complains Incompatible…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
3
votes
3 answers

C++ how convert wide string to base64?

What is the best way to convert wide string to base64?
user694655
  • 287
  • 4
  • 11
3
votes
1 answer

How to call this Delphi function from C#?

i'm having problems calling a delphi function from C# (attempted to read or write protected memory), and was wondering what the correct way of calling the method should be. The Delphi function signature is as follows: procedure methodToCall( …
oɔɯǝɹ
  • 7,219
  • 7
  • 58
  • 69
3
votes
1 answer

Does boost test have support for wide strings?

I'm just using BOOST_TEST_MESSAGE(L"blah") and the only thing that is printed out is an hex value such as 0x12345678. Am I missing some configuration? I'm using boost 1.44.
rturrado
  • 7,699
  • 6
  • 42
  • 62
3
votes
5 answers

ReadLn working with WideString (utf-8 files)

I use delphi 7. I need to read a utf-8 file line by line, each line contain a word and its weight (a number) So I need to read every next line, then divide a line by a separator (tab char) and save this in memory. So, 1) is there a library to work…
EugeneP
  • 11,783
  • 32
  • 96
  • 142
3
votes
5 answers

How to return WideString from COM server?

This Interface at _TLB.pas file // *********************************************************************// // Interface: ITMyCOM // Flags: (256) OleAutomation // GUID: {D94769D0-F4AF-41E9-9111-4D8BC2F42D69} //…
unreturned
  • 53
  • 2
  • 5
3
votes
2 answers

C++ convert between Byte vector and wstring

I need to process the data stored in wide strings at a low level. I am able to convert to a vector of Bytes with the following method: typedef unsigned char Byte; wstring mystring = L"my wide string"; Byte const *pointer = reinterpret_cast
Dia McThrees
  • 261
  • 2
  • 7
3
votes
0 answers

Convert std::string with a binary sequence of bytes into a std::wstring with character set from current locale

At the moment I read the same file twice, because I need two different representations: (a) a raw byte sequence without any conversion, (b) a text representation with bytes being converted into the current execution character set. Basically, the…
user2690527
  • 1,729
  • 1
  • 22
  • 38
3
votes
2 answers

Boost library, using std::wstring as filename with boost::property_tree::read_xml

I recently started using std::wstring instead of std::string to avoid weird results with non-ASCII characters, and I didn't find a way to read an XML file where the path is of type std::wstring using the boost library. I'm using the boost library…
Linus
  • 1,516
  • 17
  • 35