Are you sure that the file is encoded in utf8? Can you try

stream := ZnCharacterReadStream on: (File named: '...') readStream encoding: 'utf8'.
stream upToEnd.

?

If that does not work, it could mean that the file is in another encoding...

2018-01-29 18:49 GMT+01:00 Cl��ment Bera <bera.clement@gmail.com>:
Hi,

I am currently parsing lua and JSON-like file in Pharo. They contain both Simplified and Traditional Chinese characters for comments and for strings displayed in the UI. Lua files are parsed correctly. However the JSON-like files aren't.

In attachment I put one of the problematic file with Simplified chinese characters (I've also copied the file at the end of the mail). The problem can be shown as follow in Pharo:

'schinese.txt' asFileReference readStream contents

The contents function sends a��UTF8InvalidText 'Invalid utf8 input detected' error.
However my text editor correctly displays the file and it is correctly parsed by the Lua runtime (The program parsed has been deployed in production for years and works fine).

What can I do to parse this file correctly from Pharo ?

Thanks,

Below is the file content, non Chinese people may not have the font to display the characters, note that I have no idea what is written in Chinese (Please don't hold me responsible if there are offending contents):

"lang"
{
"Language" "Schinese"
"Tokens"
{
"text_store_cd" "������������������������������������������! ������������������������"
"text_cannot_huidaoguoqu" "������������������������������~"
"tips1" "������������������������������������������������������������������������~"
"tips2" "������������50������������������������������������������������������������������������"
"tips3" "������������������������������������������������������������������������������������"
"tips4" "���������������25������������������������������������������������������������������������������"
"tips5" "���10���������������������BOSS���������������������������������������~"
"tips6" "���������������������������������������������������������������������������������������~"
"tips7" "���������������������������������������������������������������������������������������������"
"tips8" "���������������������������������������������������������������������������"
"tips9" "������������������������������������������������������������������������������������������������������������~"
"tips10" "���������������������������������������������������������������������������"
"tips11" "������������������������������������������������������������������������������������������~"
"tips12" "���������������������������������������������������������������������������������������������������������"
"tips13" "���������������������������������������������10������MVP���������������������������������������"
"tips14" "������������������������������������������������������������������������������������������������������������"
"tips15" "������������������������������������������������������������������������������������������������������������~"
}
}



--
Cl��ment B��ra
Pharo consortium engineer
B��timent B 40, avenue Halley 59650��Villeneuve d'Ascq



--

������

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - http://www.cnrs.fr


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13