diff --git a/lib/service/iservice.h b/lib/service/iservice.h index 9ec1009f4c..be11e47582 100644 --- a/lib/service/iservice.h +++ b/lib/service/iservice.h @@ -57,6 +57,9 @@ public: std::string getPath() const { return path; } void setPath( const std::string &n ) { path=n; } + // getRawPath will return a bytes object in python + std::vector<char> getRawPath() const { return std::vector<char>(path.begin(), path.end()); } + unsigned int getUnsignedData(unsigned int num) const { if ( num < sizeof(data)/sizeof(int) )
How about using a new property like getRawPath?
Returning std::vector<char> will be converted directly into bytes using SWIG.
Please note that os.listdir returns both unicode string and bytes depending on the input...
>>> os.listdir(b'.') [b'M\xc3\xbcnchen.png', b'M\x81nchen.png'] >>> os.listdir(b'.')[1].decode("utf-8",errors='surrogateescape') 'M\udc81nchen.png' >>> os.listdir(b'.')[1].decode('cp437') 'München.png' ... >>> list(os.walk(b'.')) [(b'.', [], [b'M\xc3\xbcnchen.png', b'M\x81nchen.png'])] >>> list(os.walk('.')) [('.', [], ['München.png', 'M\udc81nchen.png'])]
https://docs.python....icode-filenames
The os.listdir() function returns filenames, which raises an issue: should it return the Unicode version of filenames, or should it return bytes containing the encoded versions? os.listdir() can do both, depending on whether you provided the directory path as bytes or a Unicode string.
What you think is possible to use getRawFile().decode("utf-8",errors='surrogateescape')?