Path: csiph.com!news.fcku.it!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: Base64 encode using using windows-1250 encoding Date: Sat, 9 Jun 2018 12:30:02 +0200 Organization: solani.org Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: solani.org 1528540202 2047 127.0.0.43 (9 Jun 2018 10:30:02 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sat, 9 Jun 2018 10:30:02 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 In-Reply-To: Content-Language: de-DE Cancel-Lock: sha1:GbRymfx1gc9XcXmeVDmp4/P+oNY= X-User-ID: eJwFwYkBADAEBLCVijqM46n9R2iiAkLbheLq6lrWiRGONoZvCuBEr8JydJKHU567lXofNvkZGBDa Xref: csiph.com comp.lang.javascript:35208 On 08.06.2018 at 16:21, Jupi wrote: > 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. From reading the rest of the discussion so far, it seems to me that you have some (UTF-16/UCS-2 encoded) string, and you want to base64 encode the string's CP-1250 representation. Since you have not told in which environment you're working, and since some examples used “windows”, I assume you're working in a browser enviroment, where, to my knowledge, there is no readily available solution for this task. You can, however, write your own encoding function by doing the mapping manually. A simplified, inelegant and incomplete example: function encode(str) { var map = {"š": "\x9a", "ć": "\xe6"}; var dest = ""; Array.prototype.forEach.call(str, function (ch) { dest += ch in map ? map[ch] : ch; }); return btoa(dest); } encode("Perišić"); -- Christoph M. Becker