Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Frank Kozuschnik Newsgroups: comp.lang.javascript Subject: Re: Base64 encode using using windows-1250 encoding Date: Sat, 9 Jun 2018 12:45:52 +0200 Organization: solani.org Lines: 39 Message-ID: References: <3469849.XUi3uDslzQ@PointedEars.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: solani.org 1528541151 2763 127.0.0.43 (9 Jun 2018 10:45:51 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 9 Jun 2018 10:45:51 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:euWYqlZhpQ/GPmnBvSngB0ry234= X-User-ID: eJwFwQERADEIAzBL/I22IAfG8C/hExx+vHKCjsWOzqFZDfbJa1Ma1Zh1JYNzMwL+hLZctv8eXxEb In-Reply-To: Xref: csiph.com comp.lang.javascript:35209 Evertjan.: > Jupi: > >>>> I need to encode string using Central European Windows-1250 encoding. >>>> I know how to use simple base64 but it is utf-8 encoded and I need >>>> windows-1250. > > IMHO: > > base64 translates ["encodes"] any string into a human-readable string. Base64 does not encode "strings" (= sequences of characters); it encodes sequences of octets (bytes). To "base64-encode a string", you actually perform two steps: 1. Apply a character encoding to transform the string into a sequence of bytes. 2. Base64-encode the result to get a sequence of base64 characters. I guess Jupi just wants to use Windows-1250 encoding for step 1. He could use this code on node.js: var windows1250 = require("windows-1250"); var btoa = require('btoa'); var bytes = windows1250.encode("Perišić"); var b64 = btoa(bytes); Result: b64 == "UGVyaZpp5g==" > It should[!] not matter what is in the input string, > or what encoding is used. It actually does matter which encoding is used for step 1.