#1 2014-05-23 23:21:13

Celso
Member
Registered: 2013-05-14
Posts: 55

Portuguese characters

ello

I have a settings file with Portuguese characters (eg: configuração).

How do I function RecordLoadJSON recognize these characters?

Follow my code:

   TPrograms = packed record 
     fPrograms: array of record 
        FGROUP: RawUTF8; 
        fIDProgram: integer; 
        fName: RawUTF8; 
        fDescription: RawUTF8; 
     end; 
   end; 

const 
    __TPrograms = 'FPrograms [FGROUP RawUTF8 fIDProgram integer fName RawUTF8 fDescription RawUTF8]'; 

TTextWriter.RegisterCustomJSONSerializerFromText (TypeInfo (TPrograms), __TPrograms); 

v_FileName: = 'FilePrograms.settings'; 
v_tmp: = StringFromFile (v_FileName); 
RemoveCommentsFromJSON (pointer (v_tmp)); 
RecordLoadJSON (v_programs, pointer (v_tmp), TypeInfo (TPrograms));

Offline

#2 2014-05-24 07:35:10

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: Portuguese characters

What is the content of the JSON file?
Is your JSON encoded in UTF-8?

Offline

#3 2014-05-24 13:40:28

Celso
Member
Registered: 2013-05-14
Posts: 55

Re: Portuguese characters

this is the content, part of my JSON file:

{
    "fPrograms":
    [
    {
    "fGroup": "CONFIGURAÇÃO",
        "fIDProgram": 1,
    "fName": "Program",
        "fDescription": "Programas"
    },
    {
    "fGroup": "CONFIGURAÇÃO",
        "fIDProgram": 3,
    "fName": "Form",
        "fDescription": "Configurações"
    },
    ]
}

Offline

#4 2014-05-24 20:03:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,272
Website

Re: Portuguese characters

I suspect your file is not utf8 encoded.

Offline

#5 2014-05-24 21:36:55

Celso
Member
Registered: 2013-05-14
Posts: 55

Re: Portuguese characters

Please, how do I do so that the file is in utf-8?

Offline

#6 2014-05-24 21:38:48

Celso
Member
Registered: 2013-05-14
Posts: 55

Re: Portuguese characters

An information, this file was entered by notepad

Offline

#7 2014-05-30 15:31:50

Junior/RO
Member
Registered: 2011-05-13
Posts: 207

Re: Portuguese characters

Celso, you should use a programmer's text editor, like Sublime Text and save it as UTF8 encoding.

Offline

#8 2014-05-31 11:57:39

Celso
Member
Registered: 2013-05-14
Posts: 55

Re: Portuguese characters

thanks.

Offline

Board footer

Powered by FluxBB