From: Jeff E. <jem...@fr...> - 2016-04-07 15:00:24
|
Since I use Jython primarily to script my Java application, I tend to use Java API's and would do it this way: from java.nio.charset import Charset from java.lang import String s = str(String(aByteArray,Charset.forName('UTF-8'))) but I would omit the str() part and just keep the Java String and let Jython convert if and when it needs to. s = String(aByteArray,Charset.forName('UTF-8')) On 4/7/2016 2:36 AM, Master Of The wrote: > Hi, > > I am having java byte[] available to me from JDBC driver which Id > like to convert to Jython str/unicode types (with specified charset when > converting to unicode eg. utf8). > > Whats the best way to do this? > > ... unless of course its as simple as: > > s_str = str(rs.getString(...)) > s_unicode = str(rs.getString(...)).decode('utf8') > > Regards |