feature req: Utf8ToUnicodeEx with ErrorMode
Original Reporter info from Mantis: Alextp2
-
Reporter name: CudaText man_
Original Reporter info from Mantis: Alextp2
- Reporter name: CudaText man_
Description:
https://github.com/graemeg/freepascal/blob/master/rtl/inc/ustrings.inc
Utf8ToUnicode exists. It always handles 'bad chars' like this
//Not valid UTF-8 sequence
UC:=UNICODE_INVALID; //Alexey-- ord('?')
So my app cannot detect DATA LOSS. replacing of 'bad chars' to '?' is DATA LOSS if I pass some random German text file to UTf8ToUnicode.
Feature req.
Add Utf8ToUnicodeEx with the same params + new param ErrorMode. ErrorMode is enum (eemReplace, eemException).
Utf8ToUnicode will call Utf8ToUnicodeEx with ErrorMode=eemReplace.
In my app I will call Utf8ToUnicodeEx with ErrorMode=eemException.
Change is simple: replace
//Not valid UTF-8 sequence
UC:=UNICODE_INVALID; //Alexey-- ord('?')
to call DoError(UC). DoError will be internal procedure which raises exception.
Mantis conversion info:
- Mantis ID: 38008
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 47391 (#257ef24a)
- Target version: 3.2.2