Skip to content
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

use Python-compatible unicode escapes #8748

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/cpp/core/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,18 @@ std::string utf8ToSystem(const std::string& str,
if (n == -1)
{
if (escapeInvalidChars)
output << "\\u{" << std::hex << wide[i] << "}";
{
// NOTE: in R, both '\u{1234}' and '\u1234' are valid
// ways of specifying a unicode literal, but only the
// latter is accepted by Python, and since the reticulate
// REPL uses the same conversion routines we prefer the
// format compatible with both parsers
output << "\\u" << std::hex << wide[i];
}
else
{
output << "?"; // TODO: Use GetCPInfo()
}
}
else
{
Expand Down