Questions tagged [codecvt]
48 questions
1
vote
0 answers
std::codecvt_utf8 facet erroneous output with MSYS2 Bash and CMD
Reproduce: codecvt.cpp
#include
#include
#include
#include
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
locale utf8(locale(), new codecvt_utf8);
…

Yahya Gedik
- 97
- 1
- 12
1
vote
1 answer
Wrong codecvt result in ViualStudio 2010
The following code prints "failed" to console:
#include "stdafx.h"
#include
#include
#include
#include
#include
int main(int argc, char* argv[])
{
typedef std::codecvt…

hoxnox
- 355
- 1
- 4
- 16
1
vote
1 answer
Wrong endian with wstring_convert
I recently discovered the header, so I wanted to convert between UTF-8 and UTF-16.
I use the codecvt_utf8_utf16 facet with wstring_convert from C++11.
The issue I have, is when I try to convert an UTF-16 string to UTF-8, then in UTF-16…

Dante
- 404
- 2
- 10
1
vote
1 answer
stl codecvt errors c++
i want to use the codecvt to convert the std:wstring to std::string like so
#include
#include
#include
#include
#include
//some additional code
typedef std::codecvt_utf8…

Vanya
- 411
- 1
- 5
- 21
0
votes
1 answer
Using ICU to implement my own codecvt facet
I want to implement a codecvt facet using ICU to convert from any character encoding (that ICU supports) to UTF-8 internally. I'm aware that codecvt_byname exists and that it can be used to do part of what I want as shown in this example. The…

Paul J. Lucas
- 6,895
- 6
- 44
- 88
0
votes
1 answer
How to check if construction of a new codecvt_byname succeeded
Is there a standard way to check whether construction of a new std::codecvt_byname succeeded?
I was experimenting with the following program:
// cl /nologo /Fetest_codecvt_byname.exe /EHsc test_codecvt_byname.cpp && test_codecvt_byname
// g++ -o…

Daniel Trebbien
- 38,421
- 18
- 121
- 193
0
votes
0 answers
How to convert char16_t to wchar_t to print out with wprintf
I am trying to write a function to convert a const char16_* to a const wchar_t* to use it in wprintf later on:
const wchar_t* wchart_from_char16(const char16_t*) {
???
}
int main(){
const char16_t* my = u"The Text I want to print";
const…

user3443063
- 1,455
- 4
- 23
- 37
0
votes
1 answer
Why does codecvt_utf8 give hex value as ffffff appended in beginning?
for this code -
int main()
{
std::wstring wstr = L"é";
std::wstring_convert> myconv;
std::stringstream ss;
ss << std::hex << std::setfill('0');
for (auto c : myconv.to_bytes(wstr))
{
ss <<…

user123456
- 13
- 5
0
votes
1 answer
Unable to convert std::string into std::basic_string, why?
I am facing the following problem, I am trying to convert an std::string object into an std::basic_string one, using the codecvt library. The code is the following:
#include
#include
#include
int main()
{
…

Gianluca Bianco
- 656
- 2
- 11
0
votes
1 answer
Abort in wifstream destructor
The following C++ code gets a mysterious error ("Debug Error!...abort() has been called") when the return is executed. This is Visual Studio 2017 15.6.3, and the program is a 64-bit debug build, running under 64-bit Windows 7. What is causing this…

Woody20
- 791
- 11
- 30
0
votes
0 answers
C++ utf8 string to utf16
I'd like to convert a string to a utf-16 wstring.
I wrote the following code :
std::string str = "aé"; // a test string with a French character
using cvt_type = std::codecvt_utf8_utf16;
std::wstring_convert…

winapiwrapper
- 125
- 1
- 12
0
votes
1 answer
Why is `wstring_convert` throwing a range_error?
I have C++ code which converts string that contains (ALCHEMICAL SYMBOL FOR AQUA REGIA) to u16string:
#include
#include
#include
using namespace std;
int main() {
setlocale(LC_ALL, "ru_RU.UTF-8");
string s = "";
…

diralik
- 6,391
- 3
- 28
- 52
0
votes
1 answer
C++ Cannot instantiate codecvt for writing unicode in txt file
Hell0,
i need to write a text file (csv file in facts, but nvm) supporting unicode with c++.
The source code i have to modify already works great, but only support ANSI.
It's working with a wofstream :
std::wofstream x;
CString stringToWrite;
/*
…

Spychopat
- 1
- 2
0
votes
2 answers
Accessing code points of wchar_t*
I have a function, which gets a wchar_t* as input. Now in this function I have to process code points.
Since this program should run on multiple platforms, I have very little knowledge about the encoding in the wchar_t*.
I tried to get a conversion…

abergmeier
- 13,224
- 13
- 64
- 120
0
votes
1 answer
std::codecvt::do_in method overloading vs the rest of base methods
I have overloaded do_in method of std::codecvt:
#include
#include
#include
class codecvt_to_upper : public std::codecvt {
public:
explicit codecvt_to_upper(size_t r = 0) :…

4pie0
- 29,204
- 9
- 82
- 118