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


You are not allowed to post comments on this tracker with your current authentification level.

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

Submitted by:  Robin <rdemet>
Submitted on:  Mon Oct 15 13:29:33 2012  
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: Eric Wasylishen <ericw>
Open/Closed: Closed

Tue Oct 16 19:37:34 2012, 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 Oct 16 02:56:44 2012, 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>
Project MemberIn charge of this item.
Mon Oct 15 19:20:15 2012, 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 Oct 15 13:55:39 2012, comment #1:

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

Richard Frith-Macdonald <CaS>
Project Member
Mon Oct 15 13:29:33 2012, 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>


Attached Files
file #26773:  persist.m added by rdemet (2kB - 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
  • -unavailable- added by FredKiefer (Updated the item)
  • -unavailable- added by ericw (Posted a comment)
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by rdemet (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat Dec 22 21:19:45 2012FredKieferStatusReady For Test=>Fixed
      Assigned toNone=>ericw
    Tue Oct 16 02:56:44 2012ericwStatusNeed Info=>Ready For Test
    Mon Oct 15 19:20:15 2012rdemetAttached File-=>Added persist.m, #26773
    Mon Oct 15 13:55:39 2012CaSStatusNone=>Need Info

    Back to the top

    Powered by Savane 3.1-cleanup1