Comments (3)
Intrestingly the C++11 codecvt from GCC behaves differently: It does not consume any input and returns ok
: https://godbolt.org/z/nASHeL
However https://en.cppreference.com/w/cpp/locale/codecvt/out mentions:
When performing N:M conversions, this function may return std::codecvt_base::partial after consuming all source characters (from_next == from_end). This means that another internal character is needed to complete the conversion (e.g. when converting UTF-16 to UTF-8, if the last character in the source buffer is a high surrogate).
But this is a "may".
from locale.
Intrestingly the C++11 codecvt from GCC behaves differently: It does not consume any input and returns ok: https://godbolt.org/z/nASHeL
The GCC codecvt's have some active bugs, don't take them as reference.
Regarding this bug, if the UTF-16 string ends with leading surrogate, partial
should be returned, and if it ends with unpaired trailing surrogate, error
should be returned. You would be more helpful if you post code that reproduces the bug.
from locale.
From my test suite (slightly adapted):
char buf[4] = {};
char* const to = buf;
char* const to_end = buf + 4;
char* to_next = to;
const char16_t* err_utf = u"\xD800"; // Trailing UTF-16 surrogate
std::mbstate_t mb = std::mbstate_t();
const char16_t* from = err_utf;
const char16_t* from_end = from + 1;
const char16_t* from_next = from;
cvt_type::result res = cvt.out(mb, from, from_end, from_next, to, to_end, to_next);
FWIW: The above OP contains a full explanation what happens where. Follow that to verify that indeed partial
is not returned because the state is not checked.
from locale.
Related Issues (20)
- Add test for wconv_to_utf
- [Q] Meaning of utf8_from_wide/utf8_native_with_wide HOT 1
- Std backend falls back to system locale instead of C locale on Windows HOT 8
- Stream read/write with generated locales defaults to classic format/parse HOT 4
- test_formatting failure, ICU >= 72.1
- error C2220: warning treated as error, warning C4702: unreachable code HOT 1
- icu only build on windows fails
- Boost-locale compiled with vcpkg won't pass program linking HOT 4
- Missing boost_locale on a build for Haiku HOT 5
- Bad behaviour with multiple curly braces in format string HOT 2
- Crash on macOS 14.0 HOT 8
- locale::conv::from_utf freezing on macOS14 and iOS17 because iconv library HOT 12
- boost 1.83.0 on macOS Sonoma doesn't build boost_locale.a HOT 6
- libboost_locale 1.82.0 will not build on MacOS Sonoma Intel HOT 11
- Use of boost::locale::collator crashes when not using ICU/WinAPI HOT 1
- date_time created with decimals HOT 8
- Fail to build wich cxxstd=20 on Clang HOT 6
- Boost.Locale 1.84.0: boost::locale::to_title() is no longer threadsafe under Windows with ICU HOT 2
- How to Verify boost::locale::generator? HOT 1
- Test libraries and executables should be declared EXCLUDE_FROM_ALL HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from locale.