2

We are experiencing a very anoying encoding problem which started with loopback but seems to be nodejs related. Basically, we just finished developping an API with Loopback based upon an existing SQL_ASCII encoded postgresql database. Since the API has to be in UTF-8, we try to convert the data sent through our API routes to ISO-8859-15 in order to insert them correctly in our base. No matter what iconv, utf8, iso-8859 etc. modules we tried, we couldn't get to pass ISO-8859-15 converted strings, we ended up with very strange stuff. For example :

var Iconv  = require('iconv').Iconv; 
var iconv = new Iconv('UTF-8','ISO-8859-1'); 
var label = iconv.convert("bébé").toString();

If we insert then the "label" into our database, we end up with someting like that = "b�b�" !

So we just tried to look directly in the Terminal how it behaved with a basic nodejs application (without loopback or any other framework) but it didn't turn out to be better. Once the Terminal encoding set up to "ISO Latin 1", the following code :

console.log('bébé');

Was displayed this way in the Terminal :

bébé

As if nodejs was completely unable to handle ISO-8859 strings. Are we missing something there ? Are we doomed to use UTF-8 string in order to make this work ?

manniL
  • 7,157
  • 7
  • 46
  • 72
Airzebeth
  • 41
  • 1
  • 6

0 Answers0