Index: pf/pf_items.c
===================================================================
RCS file: /cvs/public/parrot/pf/pf_items.c,v
retrieving revision 1.15
diff -u -b -r1.15 pf_items.c
--- pf/pf_items.c	9 Apr 2004 20:32:39 -0000	1.15
+++ pf/pf_items.c	11 Apr 2004 03:30:06 -0000
@@ -501,6 +501,7 @@
     size_t size;
     STRING *s;
     int wordsize = pf ? pf->header->wordsize : sizeof(opcode_t);
+    const char *encoding_name = NULL;
 
     flags = PF_fetch_opcode(pf, cursor);
     /* don't let PBC mess our internals - only constant or not */
@@ -523,9 +524,31 @@
         representation = enum_stringrep_one;
     }
     
-    s = string_make(interp, *cursor, size,
-           string_primary_encoding_for_representation(interp, representation),
-           flags);
+    /* check if we need to worry about byte order */
+    if( (representation == enum_stringrep_one) 
+        || (pf->header->byteorder == PARROT_BIGENDIAN) ) /* byte order ok*/
+    {
+        encoding_name = 
+            string_primary_encoding_for_representation(interp, 
+                                                    representation);
+    }
+    else /* byte order mismatch */
+    {
+        /* ICU has special encoding names to represent the byte-swapped
+           case, so we don't need to do that logic ourselves. That is,
+           ICU will figure out if we mean UTF-16BE or UTF-16LE, etc. */
+
+        if( representation == enum_stringrep_two )
+        {
+            encoding_name = "UTF16_OppositeEndian";
+        }
+        else // representation == enum_stringrep_four
+        {
+            encoding_name = "UTF32_OppositeEndian";
+        }
+    }
+    
+    s = string_make(interp, *cursor, size, encoding_name, flags);
 
 #if TRACE_PACKFILE
     PIO_eprintf(NULL, "PF_fetch_string(): string is: ");
