Skip to content

Commit

Permalink
Merge pull request #8748 from rstudio/bugfix/repl-python-unicode-windows
Browse files Browse the repository at this point in the history
use Python-compatible unicode escapes
  • Loading branch information
jmcphers committed Jan 19, 2021
2 parents bb4cb50 + 84b76df commit 3f69f20
Showing 1 changed file with 10 additions and 1 deletion.
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

0 comments on commit 3f69f20

Please sign in to comment.