Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #35188 > unrolled thread

Base64 encode using using windows-1250 encoding

Started byJupi <nomail@gmail.com>
First post2018-06-08 16:21 +0200
Last post2018-06-09 13:33 +0200
Articles 20 on this page of 26 — 8 participants

Back to article view | Back to comp.lang.javascript


Contents

  Base64 encode using using windows-1250 encoding Jupi <nomail@gmail.com> - 2018-06-08 16:21 +0200
    Re: Base64 encode using using windows-1250 encoding Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-06-08 20:26 +0200
      Re: Base64 encode using using windows-1250 encoding Jupi <nomail@gmail.com> - 2018-06-08 22:09 +0200
        Re: Base64 encode using using windows-1250 encoding Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-06-08 22:57 +0200
      Re: Base64 encode using using windows-1250 encoding Jupi <nomail@gmail.com> - 2018-06-09 07:02 +0200
        Re: Base64 encode using using windows-1250 encoding Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-06-09 09:25 +0200
          Re: Base64 encode using using windows-1250 encoding Jupi Krem <nomail@gmail.com> - 2018-06-09 09:52 +0200
            Re: Base64 encode using using windows-1250 encoding Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-06-09 10:12 +0200
              Re: Base64 encode using using windows-1250 encoding Jupi Krem <nomail@gmail.com> - 2018-06-09 10:25 +0200
          Re: Base64 encode using using windows-1250 encoding Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-06-09 09:53 +0200
            Re: Base64 encode using using windows-1250 encoding Jupi Krem <nomail@gmail.com> - 2018-06-09 10:01 +0200
              Re: Base64 encode using using windows-1250 encoding Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-06-09 10:17 +0200
                Re: Base64 encode using using windows-1250 encoding Jupi Krem <nomail@gmail.com> - 2018-06-09 10:32 +0200
            Re: Base64 encode using using windows-1250 encoding Jupi Krem <nomail@gmail.com> - 2018-06-09 10:02 +0200
              Re: Base64 encode using using windows-1250 encoding Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-06-09 10:20 +0200
                Re: Base64 encode using using windows-1250 encoding Jupi Krem <nomail@gmail.com> - 2018-06-09 10:29 +0200
                  Re: Base64 encode using using windows-1250 encoding Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-06-09 12:07 +0200
        Re: Base64 encode using using windows-1250 encoding "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-06-09 09:30 +0200
          Re: Base64 encode using using windows-1250 encoding Jupi Krem <nomail@gmail.com> - 2018-06-09 09:55 +0200
            Re: Base64 encode using using windows-1250 encoding "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-06-09 13:11 +0200
          Re: Base64 encode using using windows-1250 encoding Frank Kozuschnik <franko@nurfuerspam.de> - 2018-06-09 12:45 +0200
            Re: Base64 encode using using windows-1250 encoding Jupi Krem <nomail@gmail.com> - 2018-06-09 13:13 +0200
              Re: Base64 encode using using windows-1250 encoding Mickey Finn <mfinn@gmail.com> - 2018-06-14 19:22 -0300
    Re: Base64 encode using using windows-1250 encoding "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-06-09 12:30 +0200
      Re: Base64 encode using using windows-1250 encoding Jupi Krem <nomail@gmail.com> - 2018-06-09 13:14 +0200
      Re: Base64 encode using using windows-1250 encoding Yappi <nomail@gmail.com> - 2018-06-09 13:33 +0200

Page 1 of 2  [1] 2  Next page →


#35188 — Base64 encode using using windows-1250 encoding

FromJupi <nomail@gmail.com>
Date2018-06-08 16:21 +0200
SubjectBase64 encode using using windows-1250 encoding
Message-ID<pfe3di$lvq$1@sunce.iskon.hr>
Hello
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.
Here is some script to do that:
http://base64encodedecode.com
Thank you for any help

[toc] | [next] | [standalone]


#35189

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2018-06-08 20:26 +0200
Message-ID<3469849.XUi3uDslzQ@PointedEars.de>
In reply to#35188
Jupi wrote:
^^^^
Your real name belongs there.

> I need to encode string using Central European Windows-1250 encoding.

Why?

> I know how to use simple base64 but it is utf-8 encoded and I need
> windows-1250.

Base64 is a transfer encoding.  UTF-8 and Windows-1250 are character 
encodings.  They have nothing to do with each other.

One uses character encodings to encode code points of characters of 
character sets.

One uses a transfer encoding to transfer (character) codes that cannot be 
handled verbatim by a protocol or network connection.

<https://en.wikipedia.org/wiki/Base64>

<https://en.wikipedia.org/wiki/XY_problem>
<http://www.catb.org/esr/faqs/smart-questions.html>

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#35190

FromJupi <nomail@gmail.com>
Date2018-06-08 22:09 +0200
Message-ID<pfenqu$6d8$1@sunce.iskon.hr>
In reply to#35189
Hello
do you have some example of how to encode string using base64, using 
Windows-1250 encoding, please?
Thank you.

Thomas 'PointedEars' Lahn wrote :
> Jupi wrote:
> ^^^^
> Your real name belongs there.
>
>> I need to encode string using Central European Windows-1250 encoding.
>
> Why?
>
>> I know how to use simple base64 but it is utf-8 encoded and I need
>> windows-1250.
>
> Base64 is a transfer encoding.  UTF-8 and Windows-1250 are character 
> encodings.  They have nothing to do with each other.
>
> One uses character encodings to encode code points of characters of 
> character sets.
>
> One uses a transfer encoding to transfer (character) codes that cannot be 
> handled verbatim by a protocol or network connection.
>
> <https://en.wikipedia.org/wiki/Base64>
>
> <https://en.wikipedia.org/wiki/XY_problem>
> <http://www.catb.org/esr/faqs/smart-questions.html>

[toc] | [prev] | [next] | [standalone]


#35191

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2018-06-08 22:57 +0200
Message-ID<2613612.sRRZx9k90R@PointedEars.de>
In reply to#35190
Jupi wrote:
^^^^

> do you have some example of how to encode string using base64, using
> Windows-1250 encoding, please?

Please read my posting more carefully, answer my question, and do not
top-post again.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#35192

FromJupi <nomail@gmail.com>
Date2018-06-09 07:02 +0200
Message-ID<pffn0r$t08$1@sunce.iskon.hr>
In reply to#35189
Thomas 'PointedEars' Lahn expressed precisely :
> Jupi wrote:
> ^^^^
> Your real name belongs there.

Mr. Jupi Krem

>> I need to encode string using Central European Windows-1250 encoding.
>
> Why?

Because I need it.

>> I know how to use simple base64 but it is utf-8 encoded and I need
>> windows-1250.
>
> Base64 is a transfer encoding.  UTF-8 and Windows-1250 are character 
> encodings.  They have nothing to do with each other.
>
> One uses character encodings to encode code points of characters of 
> character sets.
>
> One uses a transfer encoding to transfer (character) codes that cannot be 
> handled verbatim by a protocol or network connection.
>
> <https://en.wikipedia.org/wiki/Base64>

I do not understand all this. I just need to encode some string which 
contains Easteuropean characters to base64 string. Curently, when I 
encode string, it is encoded using utf-8.
Thank you.

[toc] | [prev] | [next] | [standalone]


#35193

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2018-06-09 09:25 +0200
Message-ID<16824345.heBUIXtyyW@PointedEars.de>
In reply to#35192
Jupi wrote:

> Thomas 'PointedEars' Lahn expressed precisely :
>> Jupi wrote:
>> ^^^^
>> Your real name belongs there.
> 
> Mr. Jupi Krem

Put “Jupi Krem” in your sender field (“From”).

>>> I need to encode string using Central European Windows-1250 encoding.
>> Why?
> 
> Because I need it.

No, you just *think* you need it.

<http://xyproblem.info/>

>>> I know how to use simple base64 but it is utf-8 encoded and I need
>>> windows-1250.
>> Base64 is a transfer encoding.  UTF-8 and Windows-1250 are character
>> encodings.  They have nothing to do with each other.
>>
>> One uses character encodings to encode code points of characters of
>> character sets.
>>
>> One uses a transfer encoding to transfer (character) codes that cannot be
>> handled verbatim by a protocol or network connection.
>>
>> <https://en.wikipedia.org/wiki/Base64>
> 
> I do not understand all this.

You will have to.

> I just need to encode some string which
> contains Easteuropean characters to base64 string.

  var b64 = window.btoa("Perišić");

RTFFAQ, RTFM, STFW.

> Curently, when I encode string, it is encoded using utf-8.

No, it is not.

How did you get the idea that it would be?

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#35195

FromJupi Krem <nomail@gmail.com>
Date2018-06-09 09:52 +0200
Message-ID<pfg10q$512$1@sunce.iskon.hr>
In reply to#35193
Thomas 'PointedEars' Lahn has brought this to us :
> Jupi wrote:
>
>> Thomas 'PointedEars' Lahn expressed precisely :
>>> Jupi wrote:
>>> ^^^^
>>> Your real name belongs there.
>> 
>> Mr. Jupi Krem
>
> Put “Jupi Krem” in your sender field (“From”).

Done :')

>
>>>> I need to encode string using Central European Windows-1250 encoding.
>>> Why?
>> 
>> Because I need it.
>
> No, you just *think* you need it.

Right. I need just solution for my problem.

> <http://xyproblem.info/>
>
>>>> I know how to use simple base64 but it is utf-8 encoded and I need
>>>> windows-1250.
>>> Base64 is a transfer encoding.  UTF-8 and Windows-1250 are character
>>> encodings.  They have nothing to do with each other.
>>> 
>>> One uses character encodings to encode code points of characters of
>>> character sets.
>>> 
>>> One uses a transfer encoding to transfer (character) codes that cannot be
>>> handled verbatim by a protocol or network connection.
>>> 
>>> <https://en.wikipedia.org/wiki/Base64>
>> 
>> I do not understand all this.
>
> You will have to.
>
>> I just need to encode some string which
>> contains Easteuropean characters to base64 string.
>
>   var b64 = window.btoa("Perišić");

Result is this:
UGVyacWhacSH
and I need this:
UGVyaZpp5g==

> RTFFAQ, RTFM, STFW.
>
>> Curently, when I encode string, it is encoded using utf-8.
>
> No, it is not.
>
> How did you get the idea that it would be?
Please check here: http://base64encodedecode.com
you can select different Encoding.
What I need is "just" to encode string using Windows-1250 encoding, 
that's all. Thank you

[toc] | [prev] | [next] | [standalone]


#35200

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2018-06-09 10:12 +0200
Message-ID<3623877.9AgGOrEZyW@PointedEars.de>
In reply to#35195
Jupi Krem wrote:

> Thomas 'PointedEars' Lahn has brought this to us :
>> Jupi wrote:
>>> Thomas 'PointedEars' Lahn expressed precisely :
>>>>> I need to encode string using Central European Windows-1250 encoding.
>>>> Why?
>>> Because I need it.
>> No, you just *think* you need it.
> 
> Right. I need just solution for my problem.

This is not a support forum for Copy & Pray.
 
>> <http://xyproblem.info/>

Have you even read this?

>>> I just need to encode some string which
>>> contains Easteuropean characters to base64 string.
>>
>>   var b64 = window.btoa("Perišić");
> 
> Result is this:
> UGVyacWhacSH

In which environment?  See my update.

> and I need this:
> UGVyaZpp5g==

Hardly:

| > window.atob("UGVyaZpp5g==")
| "Perišiæ"

> […]
>>> Curently, when I encode string, it is encoded using utf-8.
>> No, it is not.
>>
>> How did you get the idea that it would be?
> Please check here: http://base64encodedecode.com

That is a Web application.  If you are asking here, you are asking to do it 
in your own code instead.

> you can select different Encoding.

So that is _not_ what I said.

Because of the limitations of Base64, they are basically using the same 
workaround as I did in my update.  For example,

  ć

is encoded as

  xIc=

as it is with

| > window.btoa(encodeURIComponent("ć").replace(/%([0-9A-F]{2})/g, (m, code) 
|   => String.fromCharCode(parseInt(code, 16))))
| "xIc="

(Our inputs and outputs match; their code is minified, so I will not bother 
to check further.)

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#35204

FromJupi Krem <nomail@gmail.com>
Date2018-06-09 10:25 +0200
Message-ID<pfg2ut$6ff$1@sunce.iskon.hr>
In reply to#35200

[Multipart message — attachments visible in raw view] — view raw

It happens that Thomas 'PointedEars' Lahn formulated :
> Jupi Krem wrote:
>
>> Thomas 'PointedEars' Lahn has brought this to us :
>>> Jupi wrote:
>>>> Thomas 'PointedEars' Lahn expressed precisely :
>>>>>> I need to encode string using Central European Windows-1250 encoding.
>>>>> Why?
>>>> Because I need it.
>>> No, you just *think* you need it.
>> 
>> Right. I need just solution for my problem.
>
> This is not a support forum for Copy & Pray.
>  

OK I understand. I will try to explain my problem.

>>> <http://xyproblem.info/>
>
> Have you even read this?

Yes, I see your point.

>>>> I just need to encode some string which
>>>> contains Easteuropean characters to base64 string.
>>> 
>>>   var b64 = window.btoa("Perišić");
>> 
>> Result is this:
>> UGVyacWhacSH
>
> In which environment?  See my update.
>
>> and I need this:
>> UGVyaZpp5g==
>
> Hardly:
>
>>> window.atob("UGVyaZpp5g==")
>> "Perišiæ"

Yes, it means atob is not good option.

>> […]
>>>> Curently, when I encode string, it is encoded using utf-8.
>>> No, it is not.
>>> 
>>> How did you get the idea that it would be?
>> Please check here: http://base64encodedecode.com
>
> That is a Web application.  If you are asking here, you are asking to do it 
> in your own code instead.
>
>> you can select different Encoding.
>
> So that is _not_ what I said.
>
> Because of the limitations of Base64, they are basically using the same 
> workaround as I did in my update.  For example,
>
>   ć
>
> is encoded as
>
>   xIc=
>
> as it is with
>
>>> window.btoa(encodeURIComponent("ć").replace(/%([0-9A-F]{2})/g, (m, code) 
>>   => String.fromCharCode(parseInt(code, 16))))
>> "xIc="

I agree but ć must be encoded as 5g== and not as xIc=
please check attached image.

> (Our inputs and outputs match; their code is minified, so I will not bother 
> to check further.)

[toc] | [prev] | [next] | [standalone]


#35196

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2018-06-09 09:53 +0200
Message-ID<3701683.oWXzg6A8BD@PointedEars.de>
In reply to#35193
Thomas 'PointedEars' Lahn wrote:

> Jupi wrote:
>> Thomas 'PointedEars' Lahn expressed precisely :
>>> Jupi wrote:
>>>> I need to encode string using Central European Windows-1250 encoding.
>>> Why?
>> 
>> Because I need it.
> 
> No, you just *think* you need it.
> 
> <http://xyproblem.info/>
> 
>> […]
>> I just need to encode some string which
>> contains Easteuropean characters to base64 string.
> 
>   var b64 = window.btoa("Perišić");

This throws

| Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to 
| be encoded contains characters outside of the Latin1 range.
|     at <anonymous>:1:8

in Chromium "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like 
Gecko) Chrome/57.0.2987.98 Safari/537.36".  So apparently there is no easy 
way.

Since ECMAScript implementations only use a Unicode-compatible 16-bit 
character encoding internally, a possibility appears to be convert the 
original string to a representation of UTF-8 first, encode the individual 
UTF-8 code units as if each of them were an ISO-8859-1 code unit, and then 
encode the resulting character string with Base64.  For that, we could use 

  var b64 = window.btoa(
    encodeURIComponent("Perišić").replace(
      /%([0-9A-F]{2})|./g,
      (m, code) => (code) ? String.fromCharCode(parseInt(code, 16)) : m)
  );

Still, the question remains: Why does Base64 have to be used in the first 
place?

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#35198

FromJupi Krem <nomail@gmail.com>
Date2018-06-09 10:01 +0200
Message-ID<pfg1go$5f1$1@sunce.iskon.hr>
In reply to#35196
It happens that Thomas 'PointedEars' Lahn formulated :
> Thomas 'PointedEars' Lahn wrote:
>
>> Jupi wrote:
>>> Thomas 'PointedEars' Lahn expressed precisely :
>>>> Jupi wrote:
>>>>> I need to encode string using Central European Windows-1250 encoding.
>>>> Why?
>>> 
>>> Because I need it.
>> 
>> No, you just *think* you need it.
>> 
>> <http://xyproblem.info/>
>> 
>>> […]
>>> I just need to encode some string which
>>> contains Easteuropean characters to base64 string.
>> 
>>   var b64 = window.btoa("Perišić");
>
> This throws
>
>> Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to 
>> be encoded contains characters outside of the Latin1 range.
>>     at <anonymous>:1:8
>
> in Chromium "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like 
> Gecko) Chrome/57.0.2987.98 Safari/537.36".  So apparently there is no easy 
> way.
>
> Since ECMAScript implementations only use a Unicode-compatible 16-bit 
> character encoding internally, a possibility appears to be convert the 
> original string to a representation of UTF-8 first, encode the individual 
> UTF-8 code units as if each of them were an ISO-8859-1 code unit, and then 
> encode the resulting character string with Base64.  For that, we could use 
>
>   var b64 = window.btoa(
>     encodeURIComponent("Perišić").replace(
>       /%([0-9A-F]{2})|./g,
>       (m, code) => (code) ? String.fromCharCode(parseInt(code, 16)) : m)
>   );
>
> Still, the question remains: Why does Base64 have to be used in the first 
> place?

Because I need to encode Perišić with windows-1250 encoding to become 
UGVyaZpp5g== and not UGVyacWhacSH like in your examples.

[toc] | [prev] | [next] | [standalone]


#35201

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2018-06-09 10:17 +0200
Message-ID<6559522.8QW5kuDgU2@PointedEars.de>
In reply to#35198
Jupi Krem wrote:

> It happens that Thomas 'PointedEars' Lahn formulated :
>> Still, the question remains: Why does Base64 have to be used in the first
>> place?
> 
> Because I need to encode Perišić with windows-1250 encoding to become
> UGVyaZpp5g== and not UGVyacWhacSH like in your examples.

That does not answer my question at all.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#35206

FromJupi Krem <nomail@gmail.com>
Date2018-06-09 10:32 +0200
Message-ID<pfg3av$6pm$1@sunce.iskon.hr>
In reply to#35201
Thomas 'PointedEars' Lahn presented the following explanation :
> Jupi Krem wrote:
>
>> It happens that Thomas 'PointedEars' Lahn formulated :
>>> Still, the question remains: Why does Base64 have to be used in the first
>>> place?
>> 
>> Because I need to encode Perišić with windows-1250 encoding to become
>> UGVyaZpp5g== and not UGVyacWhacSH like in your examples.
>
> That does not answer my question at all.

I have string (Perišić) which I need to encode and compare with 
database field. Database field contains UGVyaZpp5g== so I need to have 
same result.

[toc] | [prev] | [next] | [standalone]


#35199

FromJupi Krem <nomail@gmail.com>
Date2018-06-09 10:02 +0200
Message-ID<pfg1j0$5f5$1@sunce.iskon.hr>
In reply to#35196
It happens that Thomas 'PointedEars' Lahn formulated :
> Thomas 'PointedEars' Lahn wrote:
>
>> Jupi wrote:
>>> Thomas 'PointedEars' Lahn expressed precisely :
>>>> Jupi wrote:
>>>>> I need to encode string using Central European Windows-1250 encoding.
>>>> Why?
>>> 
>>> Because I need it.
>> 
>> No, you just *think* you need it.
>> 
>> <http://xyproblem.info/>
>> 
>>> […]
>>> I just need to encode some string which
>>> contains Easteuropean characters to base64 string.
>> 
>>   var b64 = window.btoa("Perišić");
>
> This throws
>
>> Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to 
>> be encoded contains characters outside of the Latin1 range.
>>     at <anonymous>:1:8
>
> in Chromium "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like 
> Gecko) Chrome/57.0.2987.98 Safari/537.36".  So apparently there is no easy 
> way.
>
> Since ECMAScript implementations only use a Unicode-compatible 16-bit 
> character encoding internally, a possibility appears to be convert the 
> original string to a representation of UTF-8 first, encode the individual 
> UTF-8 code units as if each of them were an ISO-8859-1 code unit, and then 
> encode the resulting character string with Base64.  For that, we could use 
>
>   var b64 = window.btoa(
>     encodeURIComponent("Perišić").replace(
>       /%([0-9A-F]{2})|./g,
>       (m, code) => (code) ? String.fromCharCode(parseInt(code, 16)) : m)
>   );

Thank you but it I have UGVyacWhacSH and I need UGVyaZpp5g==

[toc] | [prev] | [next] | [standalone]


#35203

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2018-06-09 10:20 +0200
Message-ID<3956723.jocM3bjZqr@PointedEars.de>
In reply to#35199
Jupi Krem wrote:

> It happens that Thomas 'PointedEars' Lahn formulated :
>>   var b64 = window.btoa(
>>     encodeURIComponent("Perišić").replace(
>>       /%([0-9A-F]{2})|./g,
>>       (m, code) => (code) ? String.fromCharCode(parseInt(code, 16)) : m)
>>   );
> 
> Thank you but it I have UGVyacWhacSH and I need UGVyaZpp5g==

It is known what you need.  But you have not told why.  Until you do, there 
is no way to give proper advice.

Sit back, relax, and think what brought you to believe to use Base64 for 
this in the first place.  Then tell us *that*.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#35205

FromJupi Krem <nomail@gmail.com>
Date2018-06-09 10:29 +0200
Message-ID<pfg36b$6mp$1@sunce.iskon.hr>
In reply to#35203
Thomas 'PointedEars' Lahn explained :
> Jupi Krem wrote:
>
>> It happens that Thomas 'PointedEars' Lahn formulated :
>>>   var b64 = window.btoa(
>>>     encodeURIComponent("Perišić").replace(
>>>       /%([0-9A-F]{2})|./g,
>>>       (m, code) => (code) ? String.fromCharCode(parseInt(code, 16)) : m)
>>>   );
>> 
>> Thank you but it I have UGVyacWhacSH and I need UGVyaZpp5g==
>
> It is known what you need.  But you have not told why.  Until you do, there 
> is no way to give proper advice.
>
> Sit back, relax, and think what brought you to believe to use Base64 for 
> this in the first place.  Then tell us *that*.

OK I have (for example) UGVyaZpp5g== in database which is written by 
other software/developer. Now I need to encode Perišić to get same 
result as I see in database.

[toc] | [prev] | [next] | [standalone]


#35207

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2018-06-09 12:07 +0200
Message-ID<1933241.8CYMbNPUb9@PointedEars.de>
In reply to#35205
Jupi Krem wrote:

> OK I have (for example) UGVyaZpp5g== in database which is written by
> other software/developer. Now I need to encode Perišić to get same
> result as I see in database.

And how did the Base64-encoded data get into the database in the first 
place?

I can think of no good reason to store Base64-encoded strings in a database.
Which database engine and DBMS?

If possible, permanently decode and convert the database field instead.

There is also no good reason anymore to use Windows-1250.  In a Web 
application, use UTF-8 instead.  If it is not for a Web application,
you should have said so from the start; see the FAQ.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#35194

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2018-06-09 09:30 +0200
Message-ID<XnsA8FC60AA57528eejj99@194.109.6.166>
In reply to#35192
Jupi <nomail@gmail.com> wrote on 09 Jun 2018 in comp.lang.javascript:

> Thomas 'PointedEars' Lahn expressed precisely :
>> Jupi wrote:
>> ^^^^
>> Your real name belongs there.
> 
> Mr. Jupi Krem
> 
>>> I need to encode string using Central European Windows-1250 encoding.
>>
>> Why?
> 
> Because I need it.
> 
>>> I know how to use simple base64 but it is utf-8 encoded and I need
>>> windows-1250.
>>
>> Base64 is a transfer encoding.  UTF-8 and Windows-1250 are character 
>> encodings.  They have nothing to do with each other.
>>
>> One uses character encodings to encode code points of characters of 
>> character sets.
>>
>> One uses a transfer encoding to transfer (character) codes that cannot be 
>> handled verbatim by a protocol or network connection.
>>
>> <https://en.wikipedia.org/wiki/Base64>
> 
> I do not understand all this. I just need to encode some string which 
> contains Easteuropean characters to base64 string. Curently, when I 
> encode string, it is encoded using utf-8.
> Thank you.

IMHO:

base64 translates ["encodes"] any string
into a human-readable string.

It should[!] not matter what is in the input string,
or what encoding is used.

=======================

<script type='text/javascript'> 
'use strict';

// Define the string
let str = 'Hello World!';

// Encode the String
let encodedString = btoa(str);
console.log(encodedString); // Outputs: "SGVsbG8gV29ybGQh"

// Decode the String
let decodedString = atob(encodedString);
console.log(decodedString); // Outputs: "Hello World!"

</script>

However please read these first:

<https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64
_encoding_and_decoding#The_Unicode_Problem>

<https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-
decode-base64-doesnt-properly-decode-utf-8-strings>

https://caniuse.com/#search=btoa

https://caniuse.com/#search=atob




-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#35197

FromJupi Krem <nomail@gmail.com>
Date2018-06-09 09:55 +0200
Message-ID<pfg16f$54g$1@sunce.iskon.hr>
In reply to#35194
Than you but your code works with English language - but not with 
EastEuropean.


Evertjan. formulated the question :
> Jupi <nomail@gmail.com> wrote on 09 Jun 2018 in comp.lang.javascript:
>
>> Thomas 'PointedEars' Lahn expressed precisely :
>>> Jupi wrote:
>>> ^^^^
>>> Your real name belongs there.
>> 
>> Mr. Jupi Krem
>> 
>>>> I need to encode string using Central European Windows-1250 encoding.
>>> 
>>> Why?
>> 
>> Because I need it.
>> 
>>>> I know how to use simple base64 but it is utf-8 encoded and I need
>>>> windows-1250.
>>> 
>>> Base64 is a transfer encoding.  UTF-8 and Windows-1250 are character 
>>> encodings.  They have nothing to do with each other.
>>> 
>>> One uses character encodings to encode code points of characters of 
>>> character sets.
>>> 
>>> One uses a transfer encoding to transfer (character) codes that cannot be 
>>> handled verbatim by a protocol or network connection.
>>> 
>>> <https://en.wikipedia.org/wiki/Base64>
>> 
>> I do not understand all this. I just need to encode some string which 
>> contains Easteuropean characters to base64 string. Curently, when I 
>> encode string, it is encoded using utf-8.
>> Thank you.
>
> IMHO:
>
> base64 translates ["encodes"] any string
> into a human-readable string.
>
> It should[!] not matter what is in the input string,
> or what encoding is used.
>
> =======================
>
> <script type='text/javascript'> 
> 'use strict';
>
> // Define the string
> let str = 'Hello World!';
>
> // Encode the String
> let encodedString = btoa(str);
> console.log(encodedString); // Outputs: "SGVsbG8gV29ybGQh"
>
> // Decode the String
> let decodedString = atob(encodedString);
> console.log(decodedString); // Outputs: "Hello World!"
>
> </script>
>
> However please read these first:
>
> <https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64
> _encoding_and_decoding#The_Unicode_Problem>
>
> <https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-
> decode-base64-doesnt-properly-decode-utf-8-strings>
>
> https://caniuse.com/#search=btoa
>
> https://caniuse.com/#search=atob

[toc] | [prev] | [next] | [standalone]


#35210

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2018-06-09 13:11 +0200
Message-ID<XnsA8FC861CEE53eejj99@194.109.6.166>
In reply to#35197
Jupi Krem <nomail@gmail.com> wrote on 09 Jun 2018 in comp.lang.javascript:

> Evertjan. formulated the question :
>> Jupi <nomail@gmail.com> wrote on 09 Jun 2018 in comp.lang.javascript:
>>
>>> Thomas 'PointedEars' Lahn expressed precisely :
>>>> Jupi wrote:
>>>> ^^^^
>>>> Your real name belongs there.
>>> 
>>> Mr. Jupi Krem
>>> 
>>>>> I need to encode string using Central European Windows-1250
>>>>> encoding. 
>>>> 
>>>> Why?
>>> 
>>> Because I need it.
>>> 
>>>>> I know how to use simple base64 but it is utf-8 encoded and I need
>>>>> windows-1250.
>>>> 
>>>> Base64 is a transfer encoding.  UTF-8 and Windows-1250 are character 
>>>> encodings.  They have nothing to do with each other.
>>>> 
>>>> One uses character encodings to encode code points of characters of 
>>>> character sets.
>>>> 
>>>> One uses a transfer encoding to transfer (character) codes that
>>>> cannot be handled verbatim by a protocol or network connection.
>>>> 
>>>> <https://en.wikipedia.org/wiki/Base64>
>>> 
>>> I do not understand all this. I just need to encode some string which 
>>> contains Easteuropean characters to base64 string. Curently, when I 
>>> encode string, it is encoded using utf-8.
>>> Thank you.
>>
>> IMHO:
>>
>> base64 translates ["encodes"] any string
>> into a human-readable string.
>>
>> It should[!] not matter what is in the input string,
>> or what encoding is used.
>>
>> =======================
>>
>> <script type='text/javascript'> 
>> 'use strict';
>>
>> // Define the string
>> let str = 'Hello World!';
>>
>> // Encode the String
>> let encodedString = btoa(str);
>> console.log(encodedString); // Outputs: "SGVsbG8gV29ybGQh"
>>
>> // Decode the String
>> let decodedString = atob(encodedString);
>> console.log(decodedString); // Outputs: "Hello World!"
>>
>> </script>
>>
>> However please read these first:
>>
>> <https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64
>> _encoding_and_decoding#The_Unicode_Problem>
>>
>> <https://stackoverflow.com/questions/30106476/using-javascripts-atob-to-
>> decode-base64-doesnt-properly-decode-utf-8-strings>
>>
>> https://caniuse.com/#search=btoa
>>
>> https://caniuse.com/#search=atob

[please do not toppost]

> Than you but your code works with English language - but not with 
> EastEuropean.

Nonsense, the language has nothing to do with it, as long as the letters are 
coded an you include the specific corrections on my code as shown in the 
links, I trust.

I expect a minimum of Javascript knowledge or experimenting joy on your 
part, as a Usenet NG is not a paid helpdesk.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web