summaryrefslogtreecommitdiff
path: root/src/py_utils.cc
diff options
context:
space:
mode:
authorAlexis Hildebrandt <afh@surryhill.net>2022-10-01 20:27:11 +0200
committerMartin Michlmayr <tbm@cyrius.com>2022-10-02 10:19:52 +0800
commit1f79792ec824d1792f76c4ff6d47e32affab7c8a (patch)
treeec49dc338a59e1033606e7f29f945f2d83a4e289 /src/py_utils.cc
parent4be0fc082c7d3a03f2b66fa4ffb9dbfb3d606478 (diff)
downloadfork-ledger-1f79792ec824d1792f76c4ff6d47e32affab7c8a.tar.gz
fork-ledger-1f79792ec824d1792f76c4ff6d47e32affab7c8a.tar.bz2
fork-ledger-1f79792ec824d1792f76c4ff6d47e32affab7c8a.zip
Fix handling of UCS-2 encoded strings
Add test to python/demo.py Fixes #2132
Diffstat (limited to 'src/py_utils.cc')
-rw-r--r--src/py_utils.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/py_utils.cc b/src/py_utils.cc
index d1413fec..cd44aa93 100644
--- a/src/py_utils.cc
+++ b/src/py_utils.cc
@@ -140,7 +140,7 @@ struct string_from_python
case PyUnicode_1BYTE_KIND: {
Py_UCS1* value = PyUnicode_1BYTE_DATA(obj_ptr);
if (value == 0) throw_error_already_set();
- str = std::string(value);
+ utf8::unchecked::utf16to8(value, value + size, std::back_inserter(str));
} break;
#if PY_MINOR_VERSION < 12 && Py_UNICODE_SIZE == 2
case PyUnicode_WCHAR_KIND: