Search code examples
character-encodingftpftp-client

UTF-8 Chars in FTP Greeting


I tried to use Unicode characters in my FTP server's greeting, but the client seems to read them as two different characters each. Because of this, I need a way to encode them into UTF-8. For now, I have the greeting HTML encoded because I am displaying it on a webpage, but on any other client it will display the encoding. How can I set the greeting to be parsed as UTF-8? And if I can't, then is there a way I can parse the greeting correctly?

EDIT: Answered my own question, see below.


Solution

  • I found the answer to the question. It was actually UTF-8 encoded already, and I had to decode it from UTF-8. Here is what I did:

    decodeURIComponent(escape(greeting))
    

    Don't forget to replace the line breaks with <br> if you are displaying it on a webpage like I am!

    decodeURIComponent(escape(greeting)).replace(/\n/g,'<br>')