bugGNUstep - Bugs: bug #37577, NSString fails to...

Group
 
 

bug #37577: NSString fails to persist/unpersists UTF-8 String correctly

Submitter:  Robin <rdemet>
Submitted:  Mon 15 Oct 2012 01:29:33 PM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  ericw
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 16 Oct 2012 07:37:34 PM UTC, comment #4: 


>Thanks for reporting. :-)


Thanks for fixing :-)

Just updated to revision 35701 and deployed.
Test app now works as expected.

>Big-endian seems to be the correct choice as the resulting plist loads properly on OS X


As an aside, I guess Big Endian UTF-16 would be the best interchange format for strings. Do you know if Gnustep makes any effort to ensure persisted objects are interchangeable between platforms (e.g. persisted on 64bit Linux, and restores the same on 32 bit Arm)?

Either way, thx for the fix.

Robin <rdemet>
Tue 16 Oct 2012 02:56:44 AM UTC, comment #3: 

Thanks for reporting. :-)

I committed a fix. The problem was in the binary plist writer in NSPropertyList.m, which was writing UTF-16 strings in little endian (line 3738) but reading the strings back as big endian (line 3137, line 3156). Big-endian seems to be the correct choice as the resulting plist loads properly on OS X.

Eric Wasylishen <ericw>
Group Member
Mon 15 Oct 2012 07:20:15 PM UTC, comment #2: 


Attached is a small test program to recreate the problem.

My output is:
2012-10-15 21:16:09.967 persists[19317] Set String value: english -> γερμανικών δυνάμεων στον <-some Greek
2012-10-15 21:16:09.967 persists[19317] >>DataClass setValue '(null)' now renamed to 'english -> γερμανικών δυνάμεων στον <-some Greek'
2012-10-15 21:16:09.967 persists[19317] Data class value: english -> γερμανικών δυνάμεων στον <-some Greek
2012-10-15 21:16:09.967 persists[19317] encodeWithCoder, saved string : english -> γερμανικών δυνάμεων στον <-some Greek
2012-10-15 21:16:09.969 persists[19317] -- Saved DataClass to disk.
2012-10-15 21:16:09.969 persists[19317] Loaded string value: 攀渀最氀椀猀栀 ⴀ㸀 댃딃섃밃넃봃뤃먃츃봃 됃씃봃갃밃딃줃봃 쌃쐃뼃봃 㰀ⴀ猀漀洀攀 䜀爀攀攀欀
2012-10-15 21:16:09.969 persists[19317] Loaded Data class value: 攀渀最氀椀猀栀 ⴀ㸀 댃딃섃밃넃봃뤃먃츃봃 됃씃봃갃밃딃줃봃 쌃쐃뼃봃 㰀ⴀ猀漀洀攀 䜀爀攀攀欀


Note this is built with the latest from SVN.


(file #26773)

Robin <rdemet>
Mon 15 Oct 2012 01:55:39 PM UTC, comment #1: 

Please could you provide a small test/example progrm to demonstrate exactly what you are doing.

Richard Frith-Macdonald <CaS>
Group Member
Mon 15 Oct 2012 01:29:33 PM UTC, original submission:  


When I encode an NSString  (using  encodeObject:value forKey:key) with any non ASCII characters as UTF-8 (using NSString stringWithUTF8String), the persisted string does not load back
with the same characters. Instead a much larger string is returned with completely different data.

For instance the string :
 "english -> γερμανικών δυνάμεων στον <-some Greek";

will load in as :
 攀渀最氀椀猀栀 ⴀ㸀 댃딃섃밃넃봃뤃먃츃봃 됃씃봃갃밃딃줃봃 쌃쐃뼃

This looks like a bug in either encoding or decoding of the NSString. However I tried modifying the bom.m test in NSString and could not recreate the error there, so perhaps it's in the encoding part.

I have not tried any other encodings.
Host: 64bit Linux
ICU version: ICU44
gnustep base: libgnustep-base.so.1.24.2

Robin <rdemet>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #26773:  persist.m added by rdemet (2KiB - application/octet-stream - Test program to persist an NSString containing UTF-8 string data)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by FredKiefer (Updated the item)
  • -email is unavailable- added by ericw (Posted a comment)
  • -email is unavailable- added by CaS (Posted a comment)
  • -email is unavailable- added by rdemet (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-12-22 FredKiefer StatusReady For Test Fixed
        Assigned toNone ericw
        Open/ClosedOpen Closed
    2012-10-16 ericw StatusNeed Info Ready For Test
    2012-10-15 rdemet Attached File- Added persist.m, #26773
    2012-10-15 CaS StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code