-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gltfio: enable escaped unicode for node name #7989
Conversation
bf221e9
to
e976d63
Compare
e976d63
to
71c5031
Compare
libs/gltfio/src/AssetLoader.cpp
Outdated
size_t cur = 0, idx = 0; | ||
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> conv; | ||
while ((idx = sImpl.find("\\u", cur)) != std::string::npos) { | ||
auto endIdx = sImpl.find_first_not_of("0123456789abcdefABCDEF", idx + 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to limit this to only 6 characters. Otherwise we could have input like this which causes a std::range_error: wstring_convert: to_bytes error
:
\u6211\u53EBBenjamin
(should be 我叫Benjamin)
If the character is in the Basic
Multilingual Plane (U+0000 through U+FFFF), then it may be
represented as a six-character sequence: a reverse solidus, followed
by the lowercase letter u, followed by four hexadecimal digits that
encode the character's code point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the spec link. This makes things a lot easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. My other recommendation is that to_bytes
can throw a std::range_error
error if the unicode point is not valid, but not sure if we care about handling that case since that would mean the string is malformed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that's more of the user's responsibility. Let's discuss again if/when someone files a bug on it.
71c5031
to
05a1c3a
Compare
Fixes #7846