improive handling of failed character conversion

This commit is contained in:
Richard Frith-Macdonald 2018-02-04 11:10:07 +00:00
parent 113867e9e6
commit ab670fd27a
2 changed files with 3 additions and 0 deletions

View file

@ -5,6 +5,7 @@
* Source/Additions/Unicode.m: ensure iconv handle is closed
* Source/NSLocale.m: localeIdentifierFromComponents should cope with
collation alone beng set.
* Source/GSString.m: better handling if character conversion fails.
2018-01-26 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -2120,6 +2120,7 @@ characterAtIndex_c(GSStr self, unsigned index)
unsigned int s = 1;
unichar *d = &u;
u = 0; // If conversion fails we use zero
GSToUnicode(&d, &s, &c, 1, internalEncoding, 0, 0);
}
return u;
@ -3414,6 +3415,7 @@ rangeOfCharacter_c(GSStr self, NSCharacterSet *aSet, unsigned mask,
unsigned int s = 1;
unichar *d = &u;
u = 0; // If conversion fails, we use zero
GSToUnicode(&d, &s, &c, 1, internalEncoding, 0, 0);
}
/* FIXME ... what about UTF-16 sequences of more than one 16bit value