This is probably a FAQ, and in November Robin Dunn said
that he was looking into it... so I was wondering.
Thank you!
Clark
P.S. In the intrem, do you know how to cast a unicode
string into a ascii string? Hmm. Not obvious.
This is probably a FAQ, and in November Robin Dunn said
that he was looking into it... so I was wondering.
Thank you!
Clark
P.S. In the intrem, do you know how to cast a unicode
string into a ascii string? Hmm. Not obvious.
This is probably a FAQ, and in November Robin Dunn said
that he was looking into it... so I was wondering.
Starting with 2.2.5 the wrappers call PyString_AsStringAndSize to convert
parameters into wxString objects. That function will automatically convert
unicode objects to strings using the default encoding. Beyond that I'm open
to suggestions.
P.S. In the intrem, do you know how to cast a unicode
string into a ascii string? Hmm. Not obvious.
str() ?
--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!
> P.S. In the intrem, do you know how to cast a unicode
> string into a ascii string? Hmm. Not obvious.
>str() ?
I wrote a small module to deal with the problem that works
for Py 1.5 and Py 2.0. Also enables you to use Gordon's
installer to make .exe's that use encode.
BArry
import python_compatibility
...
wxWhatever( python_compatibility( strarg ) )
...
#
# python_compatibility.py
#
# Provide compatibility between python 1.5.2 and Python 2.0
#
def _p15_encode( s ):
return s
def _p20_encode( s ):
return s.encode( 'UTF-8' )
import sys, string
version = string.split( sys.version, ' ' )
is_p20 = version[0] >= '2.0'
if is_p20:
import encodings.utf_8 # needed when turning .py into .exe
encode = is_p20 and _p20_encode or _p15_encode
Robin Dunn wrote:
Starting with 2.2.5 the wrappers call PyString_AsStringAndSize to convert
parameters into wxString objects. That function will automatically convert
unicode objects to strings using the default encoding. Beyond that I'm open
to suggestions.
And what if the string has letters of different code pages in it -
some greek or cyrillics letters or german umlauts ?
Thanks, Udo