Skip to content

NodeJS Error in decoding UTF8 MySQL Value #1580

@billypap1

Description

@billypap1
  • Node.js Version: v8.11.3

Hi,
I have a website with a chat system. This chat system has a table 'messages' and one of the columns is 'messagetext' set to utf8_general_ci(MySQL). In my website, I use php to query database. The results are ok.

In my app, i use NodeJS as backend but the results are like that: " ασδασδ ". I store greek words in this column in utf8. ( ασδασδ this is the exact value on db but in php server is decoding to utf8 successfully).

I have tried iconv-lite,iconv,utf8 decode,decode Json.

I just noticed something. When I write Καλησπέρα in a form and then send it to db, the words in column are -> ΚαλησπέÏα . I used a utf8 encoder/decoder and the actual utf8 encoding in the word Καλησπέρα is Î�αληÏ�Ï�έÏ�α . So the problem i think is decoding string to utf8. What do you think about it? How can i convert this ΚαλησπέÏα to this Î�αληÏ�Ï�έÏ�α ? You can try this here: http://cafewebmaster.com/online_tools/utf_decode. Write Καλησπέρα, encode this and then decode. You will see that the result is different from the stored result in db -> ΚαλησπέÏα.

I can't decode this ΚαλησπέÏα from node js using utf8 to this Καλησπέρα to show up in the app, i get only the value ΚαλησπέÏα as response from nodejs. When i use utf.decode with ΚαλησπέÏα it shows -> Invalid continuation byte

What can I do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions