]> granicus.if.org Git - icu/commitdiff
ICU-9267 Change buffer creation in unshapeLamAlef() function.
authorAndy Heninger <andy.heninger@gmail.com>
Wed, 18 Apr 2012 21:38:54 +0000 (21:38 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Wed, 18 Apr 2012 21:38:54 +0000 (21:38 +0000)
X-SVN-Rev: 31740

icu4j/main/classes/core/src/com/ibm/icu/text/CharsetRecog_sbcs.java

index 033612044bb504b673da157cdc620f7acb0df8b2..c386bc613c6e248a662b671bb3a62e6082a95274 100644 (file)
@@ -1204,19 +1204,18 @@ abstract class CharsetRecog_sbcs extends CharsetRecognizer {
 
         private byte[] unshapeLamAlef(byte[] inputBytes, int inputLen) {
             ByteBuffer resultBigBuffer =  ByteBuffer.allocate(inputLen*2);
-            ByteBuffer resultBuffer;
             byte unshapedLamAlef[] = {(byte)0xb1, (byte)0x56};
-
-           
+         
             for (int i=0; i<inputLen; i++){
                 if (isLamAlef(inputBytes[i]))
                     resultBigBuffer.put(unshapedLamAlef);
                 else
                     resultBigBuffer.put(inputBytes[i]);
             }
-            resultBuffer = ByteBuffer.allocate(resultBigBuffer.position());
-            resultBuffer.put(resultBigBuffer.array(),0, resultBigBuffer.position());
-            return resultBuffer.array();
+            byte[] resultBuffer = new byte[resultBigBuffer.position()];
+            resultBigBuffer.position(0);
+            resultBigBuffer.get(resultBuffer);
+            return resultBuffer;
         }
         
         private boolean isLamAlef(byte b) {