|
|
|
|||||
|
Python and Unicode
Quote:
For example, the Python implementation of the "Hello World" demo server: Code:
class PrinterI(Demo.Printer):
def printString(self, s, current=None):
print s
Code:
class PrinterI(Demo.Printer):
def printString(self, s, current=None):
print s.decode('utf8')
Code:
print s.decode('utf8').encode(locale.getpreferredencoding(), 'replace')
Likewise, in a Python client, I would like to be able to Code:
printer.printString(u"Hällö Wörld!") Code:
printer.printString(u"Hällö Wörld!".encode('utf8'))
Alternatively, if IcePy uses 8-bit strings for Slice strings, it should provide an automatic string conversion facility as in C++. Our applications have to run with a Latin1 locale for legacy reasons. In C++ this works very nice and transparent after installing a UTF-8 <-> Latin1 StringConverter, but in Python it gets ugly and increases the potential for mistakes (are encode/decode correctly applied to all strings that go over the Ice interface?). I guess the best option I currently have is to patch the C++ code of the IcePy module to install a StringConverter there? In any case, it would be nice if IcePy could marshal Unicode strings to Slice strings instead of raising a ValueError. |
|
||||||
|
Hi Christian,
Quote:
So if you want to use a replacement character, you'll probably need to write your own C++ string converter. Cheers, Bernard |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| icepatch2 unicode error | incubator | Help Center | 5 | 11-22-2006 04:04 AM |
| Python | BiT | Help Center | 1 | 09-19-2006 05:21 PM |
| UNICODE not required in 1.3 | amrufon | Comments | 1 | 03-11-2004 07:22 AM |
| unicode does not support multiple word languare. | damingyipai | Bug Reports | 4 | 03-09-2004 10:28 PM |
| Unicode question | Mr.Freeze | Help Center | 1 | 08-14-2003 07:43 AM |