From: <pj...@us...> - 2009-10-27 23:49:55
|
Revision: 6919 http://jython.svn.sourceforge.net/jython/?rev=6919&view=rev Author: pjenvey Date: 2009-10-27 23:49:37 +0000 (Tue, 27 Oct 2009) Log Message: ----------- simplify Modified Paths: -------------- trunk/jython/src/org/python/core/codecs.java Modified: trunk/jython/src/org/python/core/codecs.java =================================================================== --- trunk/jython/src/org/python/core/codecs.java 2009-10-27 22:21:57 UTC (rev 6918) +++ trunk/jython/src/org/python/core/codecs.java 2009-10-27 23:49:37 UTC (rev 6919) @@ -7,12 +7,13 @@ */ package org.python.core; -import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Iterator; +import org.python.core.util.StringUtil; + /** * Contains the implementation of the builtin codecs. * @since Jython 2.0 @@ -805,17 +806,7 @@ } public static String PyUnicode_EncodeUTF8(String str, String errors) { - final Charset utf8 = Charset.forName("UTF-8"); - final ByteBuffer bbuf = utf8.encode(str); - final StringBuilder v = new StringBuilder(bbuf.limit()); - while (bbuf.remaining() > 0) { - int val = bbuf.get(); - if (val < 0) { - val = 256 + val; - } - v.appendCodePoint(val); - } - return v.toString(); + return StringUtil.fromBytes(Charset.forName("UTF-8").encode(str)); } public static String PyUnicode_DecodeASCII(String str, int size, String errors) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |