DavidOne 0 Posted September 8, 2022 Hello, I am working with Delphi 11.1. Inspired by a Stephen Ball article I am using a TJsonTextWriter to create a RADServer endpoint response the contains data from a master-detail data relationship. To write field value in the Json text response I am using the following code: if ((ADataSet.Fields[FieldIdx] is TDateField) or (ADataSet.Fields[FieldIdx] is TSQLTimeStampField)) then Writer.WriteValue(ADataSet.Fields[FieldIdx].AsDateTime) else Writer.WriteValue(ADataSet.Fields[FieldIdx].AsString); The problem I am facing off is about accented characters like: à. When I retrieve data from the endpoint I receive the following error: Project Test.exe raised exception class EEncodingError with message 'No mapping for the Unicode character exists in the target multi-byte code page'. If the there are no accented chars in the field content I can read the resulted Json without any problems. How should I managed to encode correctly accented chars? Thank you, Davide Share this post Link to post
Lars Fosdal 1792 Posted September 8, 2022 What format is the dataset string field? Have you tried converting it to UTF-8? Share this post Link to post
Der schöne Günther 316 Posted September 8, 2022 (edited) As far as I understand, not the DB layer (TFields and stuff) is throwing the exception, but your Writer is, correct? If that's the case, have you seen its StringEscapeHandling-property? Edited September 8, 2022 by Der schöne Günther 2 Share this post Link to post
DavidOne 0 Posted September 8, 2022 1 hour ago, Der schöne Günther said: As far as I understand, not the DB layer (TFields and stuff) is throwing the exception, but your Writer is, correct? If that's the case, have you seen its StringEscapeHandling-property? Thank you, setting the StringEscapeHandling to EscapeNonAscii does the magic! Share this post Link to post