Author: leo
Date: Thu Nov 10 00:54:26 2005
New Revision: 9874

Modified:
   trunk/encodings/utf16.c
   trunk/t/op/string_cs.t
Log:
utf16 string.ord; test ord and trans_encoding to utf16

Modified: trunk/encodings/utf16.c
==============================================================================
--- trunk/encodings/utf16.c     (original)
+++ trunk/encodings/utf16.c     Thu Nov 10 00:54:26 2005
@@ -123,6 +123,7 @@ copy_to_encoding(Interp *interpreter, ST
                 &dest_len, src->strstart, src->bufused, &err);
         assert(U_SUCCESS(err));
     }
+    dest->bufused = dest_len * sizeof(UChar);
     
 #else
     real_exception(interpreter, NULL, E_LibraryNotLoadedError,
@@ -135,10 +136,13 @@ copy_to_encoding(Interp *interpreter, ST
 static UINTVAL
 get_codepoint(Interp *interpreter, const STRING *src, UINTVAL offset)
 {
-    const void *start;
+    UChar *s = (UChar*) src->strstart;
+    UINTVAL c, pos;
 
-    UNIMPL;
-    return 0;
+    pos = 0;
+    U16_FWD_N_UNSAFE(s, pos, offset);
+    U16_GET_UNSAFE(s, pos, c);
+    return c;
 }
 
 static void

Modified: trunk/t/op/string_cs.t
==============================================================================
--- trunk/t/op/string_cs.t      (original)
+++ trunk/t/op/string_cs.t      Thu Nov 10 00:54:26 2005
@@ -16,7 +16,7 @@ Tests charset support.
 
 =cut
 
-use Parrot::Test tests => 33;
+use Parrot::Test tests => 34;
 use Test::More;
 
 output_is( <<'CODE', <<OUTPUT, "basic syntax" );
@@ -532,3 +532,27 @@ output_is( <<'CODE', <<"OUTPUT", "unicod
 CODE
 t\xc3\xb6tsch
 OUTPUT
+
+output_is( <<'CODE', <<"OUTPUT", "utf16 ord, length");
+    set S0, iso-8859-1:"T�TSCH"
+    find_charset I0, "unicode"
+    trans_charset S1, S0, I0
+    find_encoding I0, "utf16"
+    trans_encoding S1, S1, I0
+    length I1, S1
+    print I1
+    print "\n"
+    null I0
+loop:
+    ord I2, S1, I0
+    print I2
+    print '_'
+    inc I0
+    lt I0, I1, loop
+    print "\n"
+    end
+CODE
+6
+84_214_84_83_67_72_
+OUTPUT
+

Reply via email to