All Questions
Tagged with unicode-string c++
66 questions
1
vote
1
answer
45
views
Error compiling a boost qi parser to skip all comments and spaces in a php code string
Following my previous question, and applying the suggestions, I have created this boost qi spirit grammar to get only 'non-comments' from a piece of PHP code in the string contents:
#include <boost/...
0
votes
0
answers
145
views
Disadvantages of using `std::wstring` for Unicode in cross-platform code?
Situation
I have a large existing Win32 C++ code-base, and I want to make it portable so that it compiles and runs on both Windows (MSCV) and Linux (gcc).
For a new project I would try to go UTF-8 ...
1
vote
2
answers
339
views
Why trying to print unicode encoded strings with cout leads to compilation error in newer C++ standards?
I tried the following printing of Unicode characters with Visual C++ 2022 Version 17.4.4 with C++ standard set to the latest.
#include <iostream>
using namespace std;
int main()
{
cout <&...
0
votes
2
answers
225
views
How would I print a multi-line (non-standard) unicode string of text in C++? Updated for Clarity! (hopefully)
Rewriting this question with a bit more knowledge on what I'm requesting; (Thank you James Risner and Turtle for your assistance, but I didn't word this correctly and got different responses than what ...
0
votes
2
answers
234
views
C++ unicode strings - the basic_strings know nothing about Unicode?
I see here that the C++ standard library now has typedefs of std::basic_string like u8string and u16string, but I don't see any member functions or algorithms that know much of anything about Unicode.
...
0
votes
1
answer
403
views
Strange unicode error when converting Chinese wide strings to regular strings in C++
Some of my Chinese software users noticed a strange C++ exception being thrown when my C++ code for Windows tried to list all running processes:
在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符。
Translated to ...
1
vote
1
answer
801
views
How to get argv as LPWSTR* and not char** from command line arguments?
I am writing a small C++ program which gets as input from the program command line, a string to later be passed to another function.
The problem is that this function expects to get a LPWSTR (wchar_t*)...
0
votes
0
answers
1k
views
How to create one UNICODE_STRING from another UNICODE_STRING
Is there any better way to deep copy clone UNICODE_STRING?
This is what I tried.
int main()
{
//This is what I have.
UNICODE_STRING oldString = RTL_UNICODE_STRING("This is test string.&...
1
vote
1
answer
80
views
Visual Studio C++ outputting �� instead of 汉字?
I am trying to print out the string 汉字 in Visual Studio 2019 C++.
Something I think I should say is probably, I'm on Windows 10 and I have been trying to figure this out using the internet for an hour ...
0
votes
1
answer
2k
views
Compiling Unicode with Visual Studio 2019
I try to compile this C++17 code on VS2019:
int main() {
if(!testCodepointEncode(U'\u221A', '\xFB') ||
!testCodepointEncode(U'\u0040', '\x40') ||
!testCodepointEncode(U'\u03A3', '\xE4') |...
0
votes
1
answer
418
views
WideCharToMultiByte not converting Japanese on English OS
I need to convert file names from System.String into std::string. I am using both Japanese and English file names.
For English file names, there is no issue.
Only Japanese file names are not ...
0
votes
1
answer
753
views
How to print 4 byte Unicode character in Windows C++ console app?
How to print "👩" emoji (Unicode code 1F469) in Windows console app using C++?
In example below I followed Printing UTF-8 Text to the Windows Console.
#include <iostream>
#include <io.h>
...
1
vote
0
answers
733
views
Kernel Mode Driver BSOD PAGE_FAULT_IN_NONPAGED_AREA using a global UNICODE_STRING in Callback
I get a BSOD issue (PAGE_FAULT_IN_NONPAGED_AREA) it only started happening when I added my UNICODE_STRING
The system crash happens after the UNICODE_STRING is set and working after like 10 minutes or ...
0
votes
0
answers
247
views
ICU::UnicodeString find the indexOf a code point, not a code unit
ICU::UnicodeString's IndexOf method(https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classicu_1_1UnicodeString.html#add90e508b078575eae3d04e596c88dc2) returns the index of the first code ...
2
votes
2
answers
4k
views
How to get C++ std::string from Little-Endian UTF-16 encoded bytes
I have a 3rd party device that communicates with my Linux box over a proprietary communication protocol that isn't well documented. Some packets convey "strings" that, after reading this Joel On ...
0
votes
2
answers
1k
views
Search for character in UNICODE_STRING
There is a UNICODE_STRING and I want to check if there is a defined character in it (better: $ at the end).
We are using the OpenPasswordFilter and want to check if the submitted account is a user or ...
0
votes
1
answer
1k
views
How to convert PyObject to UTF-8 string?
I'm trying to pass a string value to a Python function and get a utf-8 string value. The function retrieves Japanese characters and returns characters in another language.
I used ctypes.windll.user32....
0
votes
0
answers
442
views
Why does `ofstream` miss some lines when writing to file?
I have generated a bunch of UTF-16LE strings (3.8k+, \n-terminated) to write to a text file, still in UTF16. Somehow a part of these strings (~1.7k) are missing in the final file. The bug is not ...
2
votes
0
answers
66
views
std::wcout, why is the printed character not the same as the input? [duplicate]
While attempting to print "é" with std::wcout the output console instead prints "Ú"
https://www.utf8-chartable.de/unicode-utf8-table.pl using this website I tried to print "é" using both L"é" or it'...
0
votes
2
answers
250
views
C++ writing to mongo, string fields not working in aggregation pipeline
**
Quick summary: C++ app loading data from SQL server using using OTL4, writing to Mongo using mongocxx bulk_write, the strings seem to getting mangled somehow so they don't work in the aggregation ...
4
votes
3
answers
3k
views
C++ output Unicode in variable
I'm trying to output a string containing unicode characters, which is received with a curl call. Therefore, I'm looking for something similar to u8 and L options for literal strings, but than ...
0
votes
0
answers
82
views
c++ windows: Is there a way to convert from _UNICODE_STRING to std::string? [duplicate]
Beginner c++ developer, here. I'm writing a program Under Windows10 with Character set = Use Unicode Character Set in the properties tab.
I'm trying to use an API to returns a _UNICODE_STRING (...
-1
votes
2
answers
51
views
Printing Unicodes in C++
How to print Unicode in Loop in C++?
I Tried with this code.It does not work
#include <iostream>
int main()
{
wchar_t chr1=L'\u0985';
while(chr1<=L'\u098C')
std::wcout<<(...
1
vote
2
answers
3k
views
How to convert UnicodeString to windows-1251 using ICU library in c++ Linux?
I have this code, which convert UTF-8 string to Unicode:
#include <unicode/unistr.h>
//included other header files
int main(int argc, char** argv) {
std::string s("some string");
//...
0
votes
1
answer
3k
views
How to do string operations with Win32 WCHAR
I have a win32 project in which I'm trying to edit the characters of a WCHAR string with a custom function.
I know this stands for Wide Char and is Unicode, however I don't fully grasp how the ...
3
votes
3
answers
2k
views
Filter Unicode characters in character array [closed]
I have character array which may or may not contain Unicode characters. When present, it will be a mixture of Unicode and ASCII characters. I need to find a way to filter out Unicode characters while ...
6
votes
2
answers
1k
views
c++ towupper() doesn't convert certain characters
I use Borland C++ Builder 2009 and my application is translated into several languages, including Polish.
For a small piece of functionality I use towuppper() to capitalize a string, to put emphasis ...
1
vote
2
answers
8k
views
UNICODE_STRING to wchar_t* null terminated
I want to use the buffer from a UNICODE_STRING, but it seems I cannot just directly use it, by copying reference, because sometime I can see that there are null bytes in the middle of a string, and ...
0
votes
1
answer
72
views
Print Universal Characters (html) stored in a string c++
I am trying to print a string with universal characters stored in it. If i initialized the string with the following:
string test = "\u000D\u000A\u000D\u000Aclass Solution {\u000D\u000Apublic:\u000D\...
3
votes
2
answers
398
views
Any caveats when searching for a UTF-8 code point in a string?
If I have some string to be searched in UTF-8 and another to search for, also in UTF-8, are there any caveats to doing a straight up comparison search for the codepoint to pinpoint a matching ...
0
votes
2
answers
389
views
Extension of c++ constructor/typedef
Extension of C++ constructor in Borland C++Builder.
I have some code that concatenates UnicodeString values (previously AnsiString).
UnicodeString string="test1";
Variant v1="test";
string = string ...
0
votes
1
answer
3k
views
convert unicodestring to string in xrad studio
I have a problem in "Rad Studio 10 Seattle" where I am trying to get text input from a TEdit object and I get a errormessage saying
E2034 Cannot convert 'UnicodeString' to 'string'
My code is as ...
0
votes
1
answer
843
views
printing char* string argument into UnicodeString object
Is it possible to print char* argument into UnicodeString object via printf member function?
Following code gives me a wrong result (damaged string):
UnicodeString s;
s.printf(L"%s", "hello");
If I ...
4
votes
3
answers
9k
views
AnsiString as default for type string in Embarcadero C++ Builder?
I have inherited an old Borland C++ Builder application which I now must migrate to a new development tool. The suggested way to go is with Embarcadero C++ Builder, and from my initial tests it seems ...
-2
votes
2
answers
1k
views
Declaring a std::string after Unicode to ASCII conversion is giving Segmentation fault
I am trying to take a wchar_t string from stdin and then convert it from unicode to ASCII through a function.
The function is somehow not allowing me to use std::string further in the program.
#...
-2
votes
1
answer
570
views
simple sum of Unicode symbol codes
I want to do this:
1) Click event of Convert ! button
User must type 2 value into writable edit controls. After pressing Convert ! program must set sum of these characters Unicode values to first ...
0
votes
1
answer
1k
views
RtlStringCbPrintf is not in ntstrsafe.h as described
I am trying to use RtlStringCbPrintf with Winsock Kernel. I have included Ntstrsafe.h but the compiler gives me the error
Error 4 error C3861: 'RtlStringCbPrintf': identifier not found c:\bw\...
1
vote
1
answer
4k
views
std::string conversion to char32_t (unicode characters)
I need to read a file using fstream in C++ that has ASCII as well as Unicode characters using the getline function.
But the function uses only std::string and these simple strings' characters can not ...
0
votes
2
answers
1k
views
Reading and write strings in binary files c++
I'm trying to develop a small Windows application to improve my C++ skill outside MFC framework and to help my studies about foreign languages.I would like to make a small, personal and easy-to-...
0
votes
1
answer
1k
views
XE5 Ansi/Unicode-String Linker Errors (Unresolved Externals)
Getting many versions of the following linker error in XE5.
[ilink32 Error] Error: Unresolved external '__stdcall System::UnicodeString::~UnicodeString()' referenced from <Location>
From ...
1
vote
2
answers
248
views
Error converting NSString to C-String
I am trying to convert NSString to C-String` using the following call:
NSString* path = ...
const char* str = [path cStringUsingEncoding: NSUTF16StringEncoding];
The path contains a file path. But, ...
3
votes
1
answer
1k
views
ASCII characters not printed in WCOUT and COUT
I am trying to print some "special" characters (above 127) in the console, but somehow it doesn't get printed.
I have this small code snippet:
#include <iostream>
int main()
{
std::wcout &...
0
votes
2
answers
3k
views
Embarcadero Cannot cast from 'UnicodeString' to 'unsigned char *'
I'm using Embarcadero's C++ builder XE
String command1 = "FREQ ";
String command2 = " Mhz\n";
int index = Form1->ListBox1->ItemIndex;
String full = command1.operator +=(IntToStr((index+2)*10))....
5
votes
2
answers
2k
views
Convert between string, u16string & u32string using libstdc++
I found this topic Convert between string, u16string & u32string and the solution (which looks really great) works only using libc++ not libstdc++. Currently libc++ is not usable - it is hard to ...
2
votes
2
answers
9k
views
Easiest way to convert UnicodeString to const char* in c++?
I'm new in c++ and have problem with converting UnicodeString to string, so now searching for easiest method to convert from one type to other.
I want to use basic windows function which needs string ...
3
votes
2
answers
3k
views
MFC CString Linker error between two projects
I have 2 projects in c++ (MFC)
One is a library project which im using in the second one (an executable one).
They work together great, until I call a function from the regular project that takes a ...
0
votes
2
answers
2k
views
Diffence with AnsiString and AnsiString transfered from UnicodeString in C++ builder
I am using C++ Builder XE3 and I have met a weird problem with AnsiString.
Just look at below code
//Code 1: first time
AnsiString temp1 = "test" ;
funcA(temp1,temp1);
//Code 2: second time
...
4
votes
1
answer
3k
views
What are "Best Practices" for a Cross-Platform string class to implement good model portability? [closed]
There are a myriad of discussion threads on the subject of cross-platform Unicode string usage, but it seems there's is a wide range of opinion, without addressing some specific concerns that've been ...
13
votes
5
answers
9k
views
How do I use 3 and 4-byte Unicode characters with standard C++ strings?
In standard C++ we have char and wchar_t for storing characters. char can store values between 0x00 and 0xFF. And wchar_t can store values between 0x0000 and 0xFFFF. std::string uses char, so it can ...
3
votes
3
answers
3k
views
UTF-8 decoding library
I have to code in an application which is in Unicode UTF-8 in Windows, MSVC 10. I'm aware that the UTF-8 encoded strings would use either 1 or 2 bytes per character. So, my question is : Is std::...