Jump to content
Registration disabled at the moment Read more... ×
Sign in to follow this  
Jacek Laskowski

PythonEngine.PyUnicode_FromString() issue

Recommended Posts

If the data variable contains any character outside the Latin alphabet, such as a Polish diacritical chars, the function returns nil

 

 data: AnsiString = 'ąęść';


  pObj := fPyEngine.PyUnicode_FromString(PAnsiChar(data)); <-- return nil
  fPyModule.SetVar('data', pObj); <-- then this raises an exception

How to properly pass diacritical chars in a string?

 

ps. the function has Unicode in its name, which means it should probably allow arbitrary characters

Edited by Jacek Laskowski

Share this post


Link to post

Why are you expecting ANSI encodings to be of use? Why aren't you using Unicode, either UTF8 or UTF16. 

 

I believe the function you call expects UTF8 which of course you are not passing. Then again I'm not sure why you picked on this function to make a string. 

Edited by David Heffernan
  • Like 1

Share this post


Link to post

P4D provides a function:

 

function TPythonEngine.PyUnicodeFromString(const AString : UnicodeString) : PPyObject;

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×