1 Aug 00:43
On String, PyString and PyUnicode
From: Leo Soto M. <leo.soto <at> gmail.com>
Subject: On String, PyString and PyUnicode
Newsgroups: gmane.comp.lang.jython.devel
Date: 2008-07-31 22:46:42 GMT
Subject: On String, PyString and PyUnicode
Newsgroups: gmane.comp.lang.jython.devel
Date: 2008-07-31 22:46:42 GMT
Hi folks,
Short History:
I don't think that java Strings should be mapped to PyString. They
should be mapped to PyUnicode. Any obvious reason why I may be wrong?
Whole History:
I was trying to implement unicodedata.normalize. It ought to be
straightforward, by delegating to java.text.Normalizer.normalize.
Here is the code:
from java.text import Normalizer;
_forms = {
'NFC': Normalizer.Form.NFC,
'NFKC': Normalizer.Form.NFKC,
'NFD': Normalizer.Form.NFD,
'NFKD': Normalizer.Form.NFKD
}
def normalize(form, unistr):
"""
Return the normal form 'form' for the Unicode string unistr. Valid
values for form are 'NFC', 'NFKC', 'NFD', and 'NFKD'.
"""
return Normalizer.normalize(unistr, _forms[form])
But it isn't right. Normalizer.normalize returns a String, which is
(Continue reading)
RSS Feed