Questions tagged [codecvt]
48 questions
94
votes
4 answers
Deprecated header replacement
A bit of foreground: my task required converting UTF-8 XML file to UTF-16 (with proper header, of course). And so I searched about usual ways of converting UTF-8 to UTF-16, and found out that one should use templates from .
But now when it…

login_not_failed
- 1,121
- 2
- 11
- 19
45
votes
4 answers
Is codecvt not a std header?
This code compiles with Visual C++ 11 and runs as expected on Windows 7 but fails to compile using either MinGW 4.7.0 on Windows 7 or gcc 4.8.0 on Linux. Compiling with -std=c++11 flag
#include
#include
// convert UTF-8 string to…

user841550
- 1,067
- 3
- 16
- 25
16
votes
3 answers
Stumped with Unicode, Boost, C++, codecvts
In C++, I want to use Unicode to do things. So after falling down the rabbit hole of Unicode, I've managed to end up in a train wreck of confusion, headaches and locales.
But in Boost I've had the unfortunate problem of trying to use Unicode file…

Jookia
- 6,544
- 13
- 50
- 60
13
votes
2 answers
How do I write a std::codecvt facet?
How do I write a std::codecvt facet? I'd like to write ones that go from UTF-16 to UTF-8, which go from UTF-16 to the systems current code page (windows, so CP_ACP), and to the system's OEM codepage (windows, so CP_OEM).
Cross-platform is preferred,…

Billy ONeal
- 104,103
- 58
- 317
- 552
9
votes
1 answer
Why is std::codecvt only used by file I/O streams?
I've been implementing a codecvt for handling indentiation of output streams. It can be used like this and works fine:
std::cout << indenter::push << "im indentet" << indenter::pop << "\n im not..."
However, while I can imbue an std::codecvt to any…

user3520616
- 60
- 3
- 17
9
votes
2 answers
Reading/writing/printing UTF-8 in C++11
I have been exploring C++11's new Unicode functionality, and while other C++11 encoding questions have been very helpful, I have a question about the following code snippet from cppreference. The code writes and then immediately reads a text file…

Ephemera
- 8,672
- 8
- 44
- 84
6
votes
1 answer
Linker error using VS 2015 RC, can't find symbol related to std::codecvt
I'm getting an STL-related link error, using Microsoft Visual Studio Community 2015 RC (Version 14.0.22823.1 D14REL)
I'm linking a C++ DLL and successfully using many functions from the STL, but it can't find stuff related to std::codecvt:
error…

topspin
- 161
- 2
- 9
6
votes
1 answer
How to read utf-16 file into utf-8 std::string line by line
I'm working with code that expects utf8-encoded std::string variables. I want to be able to handle a user-supplied file that potentially has utf-16 encoding (I don't know the encoding at design time, but eventually want to be able to deal with…

Hoobajoob
- 2,748
- 3
- 28
- 33
5
votes
2 answers
trouble with std::codecvt_utf8 facet
Here is a snippet of a code that is using std::codecvt_utf8<> facet to convert from wchar_t to UTF-8. With Visual Studio 2012, my expectations are not met (see the condition at the end of the code). Are my expectations wrong? Why? Or is this a…

wilx
- 17,697
- 6
- 59
- 114
5
votes
3 answers
streams, stream_bufs, codecvt facets and \n to \r\n translation
What part of the C++ IO streams does the \r to \r\n conversion? Is it the stream_buf itself or is it part of the internal to external encoding conversion by codecvt facet?
UPDATE 1
You all say that it is done in streambuf/filebuf. Ok. But how does…

wilx
- 17,697
- 6
- 59
- 114
3
votes
2 answers
Problem installing odbc R package on Windows
I want to install odbc R package but installation failed.
Apparently, I miss codecvt, but I don't know wat it is and how to get it.
Somebody can help me?
Thanks
I obtained the following messages :
** package 'odbc' correctement décompressé et sommes…

sylvaine31
- 41
- 3
3
votes
1 answer
How do you use wstring_convert to convert between utf16 and utf32?
When you are going from std::u16string to, lets say std::u32string, std::wstring_convert doesn't work as it expects chars. So how does one use std::wstring_convert to convert between UTF-16 and UTF-32 using std::u16string as input?
For example…

scx
- 3,221
- 1
- 19
- 37
3
votes
2 answers
parsing strings with value modifiers ('-', '%') at the end
I try to get to grips with parsing.
I have some data that comes in a de-de format with additional information at the end of the string.
I managed to get the de-de part correct but I struggle in getting the - and % parsed correctly. I read up on…

Johannes
- 6,490
- 10
- 59
- 108
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
1 answer
Is there in locale/codecvt a proper facet to test for character specifics
Well in C++ codecvt/locale library is there a proper facet one could use to test if a character "is" something? IE to test if a character is any form of linebreaking character, or represents a numeric or a whitespace etc etc?
Or would one have to go…

paul23
- 8,799
- 12
- 66
- 149