utf8

Hi

How can I transform the number to the character?

'ß' -> 223 -> 223 .chr does not work

how an I convert the two byte-numbers [195, 159] to the utf8-number ?
(or can this only be done by a lookup-table?)

thank you

Opti

Hi Opti

"%c" % 223

=> "ß"

see docs: Class: String (Ruby 3.0.2)

···

On Fri, Sep 3, 2021 at 6:45 PM Die Optimisten <inform@die-optimisten.net> wrote:

Hi

How can I transform the number to the character?

'ß' -> 223 -> 223 .chr does not work

how an I convert the two byte-numbers [195, 159] to the utf8-number ?
(or can this only be done by a lookup-table?)

thank you

Opti

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Also have a look at #pack

···

On Sat, 4 Sep 2021, 02:46 Die Optimisten, <inform@die-optimisten.net> wrote:

Hi

How can I transform the number to the character?

'ß' -> 223 -> 223 .chr does not work

how an I convert the two byte-numbers [195, 159] to the utf8-number ?
(or can this only be done by a lookup-table?)

thank you

Opti

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

223.chr('utf-8')

···

On 9/3/21 6:44 PM, Die Optimisten wrote:

Hi

How can I transform the number to the character?

'ß' -> 223 -> 223 .chr does not work

how an I convert the two byte-numbers [195, 159] to the utf8-number ?
(or can this only be done by a lookup-table?)

thank you

Opti

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Thank you, any ideas to the two-byte numbers?

Opti

···

Am 03.09.21 um 21:34 schrieb Matthew Kerwin:

Also have a look at #pack
Class: Array (Ruby 3.0.0)

On Sat, 4 Sep 2021, 02:46 Die Optimisten, <inform@die-optimisten.net > <mailto:inform@die-optimisten.net>> wrote:

    Hi

    How can I transform the number to the character?

    'ß' -> 223 -> 223 .chr does not work

    ---> how an I convert the two byte-numbers [195, 159] to the
    utf8-number ?
    (or can this only be done by a lookup-table?)

    thank you

    Opt

irb(main):001:0> (195*256+159).chr('utf-8')
=> "쎟"

Is it the right answer ?

Michel.

Le 04/09/2021 à 20:32, Die Optimisten a écrit :

···

Thank you, any ideas to the two-byte numbers?

Opti

Am 03.09.21 um 21:34 schrieb Matthew Kerwin:

Also have a look at #pack Class: Array (Ruby 3.0.0)

On Sat, 4 Sep 2021, 02:46 Die Optimisten, <inform@die-optimisten.net >> <mailto:inform@die-optimisten.net>> wrote:

    Hi

    How can I transform the number to the character?

    'ß' -> 223      -> 223 .chr does not work

    ---> how an I convert the two byte-numbers [195, 159] to the
    utf8-number ?
    (or can this only be done by a lookup-table?)

    thank you

    Opt

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

it is !

irb(main):001:0> (195*256+159).chr('utf-8')
=> "쎟"

  ìŽŸ Hangul Syllable Sseh

    U+C39F

Le 04/09/2021 à 21:11, Michel Revesche a écrit :

···

irb(main):001:0> (195*256+159).chr('utf-8')
=> "쎟"

Is it the right answer ?

Michel.

Le 04/09/2021 à 20:32, Die Optimisten a écrit :

Thank you, any ideas to the two-byte numbers?

Opti

Am 03.09.21 um 21:34 schrieb Matthew Kerwin:

Also have a look at #pack Class: Array (Ruby 3.0.0)

On Sat, 4 Sep 2021, 02:46 Die Optimisten, <inform@die-optimisten.net >>> <mailto:inform@die-optimisten.net>> wrote:

    Hi

    How can I transform the number to the character?

    'ß' -> 223      -> 223 .chr does not work

    ---> how an I convert the two byte-numbers [195, 159] to the
    utf8-number ?
    (or can this only be done by a lookup-table?)

    thank you

    Opt

Unsubscribe:<mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Hi,
no, should be 'ß'... (223)

···

Am 04.09.21 um 21:29 schrieb Michel Revesche:

it is !

irb(main):001:0> (195*256+159).chr('utf-8')
=> "쎟"

  쎟 Hangul Syllable Sseh

    U+C39F

Le 04/09/2021 à 21:11, Michel Revesche a écrit :

irb(main):001:0> (195*256+159).chr('utf-8')
=> "쎟"

Is it the right answer ?

Michel.

Le 04/09/2021 à 20:32, Die Optimisten a écrit :

Thank you, any ideas to the two-byte numbers?

Opti

Am 03.09.21 um 21:34 schrieb Matthew Kerwin:

Also have a look at #pack
Class: Array (Ruby 3.0.0)

On Sat, 4 Sep 2021, 02:46 Die Optimisten, >>>> <inform@die-optimisten.net <mailto:inform@die-optimisten.net>> wrote:

    Hi

    How can I transform the number to the character?

    'ß' -> 223 -> 223 .chr does not work

    ---> how an I convert the two byte-numbers [195, 159] to the
    utf8-number ?
    (or can this only be done by a lookup-table?)

    thank you

    Opt

Indeed, UTF-8 isn't just a shift-and-add format.

I tried to hint at it earlier, but what about something like this?

···

~~~
[195, 159].pack('C*').force_encoding('utf-8')
~~~

You can look up what Array#pack and String#force_encoding do.

Cheers

On Sun, Sep 5, 2021 at 6:15 AM Die Optimisten <inform@die-optimisten.net> wrote:

Hi,
no, should be 'ß'... (223)

Am 04.09.21 um 21:29 schrieb Michel Revesche:

it is !

irb(main):001:0> (195*256+159).chr('utf-8')
=> "쎟"
쎟 Hangul Syllable Sseh U+C39F
Le 04/09/2021 à 21:11, Michel Revesche a écrit :

irb(main):001:0> (195*256+159).chr('utf-8')
=> "쎟"

Is it the right answer ?

Michel.
Le 04/09/2021 à 20:32, Die Optimisten a écrit :

Thank you, any ideas to the two-byte numbers?

Opti

Am 03.09.21 um 21:34 schrieb Matthew Kerwin:

Also have a look at #pack
Class: Array (Ruby 3.0.0)

On Sat, 4 Sep 2021, 02:46 Die Optimisten, <inform@die-optimisten.net> > wrote:

Hi

How can I transform the number to the character?

'ß' -> 223 -> 223 .chr does not work

---> how an I convert the two byte-numbers [195, 159] to the utf8-number ?
(or can this only be done by a lookup-table?)

thank you

Opt

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
  Matthew Kerwin
  https://matthew.kerwin.net.au/

[195,159] is [C3, 9F] in hexadecimal

https://unicode-table.com/en/C39F/

Why it should be 'ß' like 223 ?

Regards
Michel

Le 05/09/2021 à 01:32, Matthew Kerwin a écrit :

···

Indeed, UTF-8 isn't just a shift-and-add format.

I tried to hint at it earlier, but what about something like this?

~~~
[195, 159].pack('C*').force_encoding('utf-8')
~~~

You can look up what Array#pack and String#force_encoding do.

Cheers

On Sun, Sep 5, 2021 at 6:15 AM Die Optimisten > <inform@die-optimisten.net <mailto:inform@die-optimisten.net>> wrote:

    Hi,
    no, should be 'ß'... (223)

    Am 04.09.21 um 21:29 schrieb Michel Revesche:

    it is !

    irb(main):001:0> (195*256+159).chr('utf-8')
    => "쎟"

      ìŽŸ Hangul Syllable Sseh

        U+C39F

    Le 04/09/2021 à 21:11, Michel Revesche a écrit :

    irb(main):001:0> (195*256+159).chr('utf-8')
    => "쎟"

    Is it the right answer ?

    Michel.

    Le 04/09/2021 à 20:32, Die Optimisten a écrit :

    Thank you, any ideas to the two-byte numbers?

    Opti

    Am 03.09.21 um 21:34 schrieb Matthew Kerwin:

    Also have a look at #pack
    Class: Array (Ruby 3.0.0)

    On Sat, 4 Sep 2021, 02:46 Die Optimisten, >>>>> <inform@die-optimisten.net <mailto:inform@die-optimisten.net>> >>>>> wrote:

        Hi

        How can I transform the number to the character?

        'ß' -> 223      -> 223 .chr does not work

        ---> how an I convert the two byte-numbers [195, 159] to
        the utf8-number ?
        (or can this only be done by a lookup-table?)

        thank you

        Opt

    Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org
    <mailto:ruby-talk-request@ruby-lang.org>?subject=unsubscribe>
    <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
 Matthew Kerwin
https://matthew.kerwin.net.au/

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

···

On Sun, Sep 5, 2021 at 4:55 PM Michel Revesche <michel.revesche@wanadoo.fr> wrote:

[195,159] is [C3, 9F] in hexadecimal

https://unicode-table.com/en/C39F/
Why it should be 'ß' like 223 ?

Regards
Michel

Le 05/09/2021 à 01:32, Matthew Kerwin a écrit :

Indeed, UTF-8 isn't just a shift-and-add format.

I tried to hint at it earlier, but what about something like this?

~~~
[195, 159].pack('C*').force_encoding('utf-8')
~~~

You can look up what Array#pack and String#force_encoding do.

Cheers

On Sun, Sep 5, 2021 at 6:15 AM Die Optimisten <inform@die-optimisten.net> > wrote:

Hi,
no, should be 'ß'... (223)

Am 04.09.21 um 21:29 schrieb Michel Revesche:

it is !

irb(main):001:0> (195*256+159).chr('utf-8')
=> "쎟"
쎟 Hangul Syllable Sseh U+C39F
Le 04/09/2021 à 21:11, Michel Revesche a écrit :

irb(main):001:0> (195*256+159).chr('utf-8')
=> "쎟"

Is it the right answer ?

Michel.
Le 04/09/2021 à 20:32, Die Optimisten a écrit :

Thank you, any ideas to the two-byte numbers?

Opti

Am 03.09.21 um 21:34 schrieb Matthew Kerwin:

Also have a look at #pack
Class: Array (Ruby 3.0.0)

On Sat, 4 Sep 2021, 02:46 Die Optimisten, <inform@die-optimisten.net> >> wrote:

Hi

How can I transform the number to the character?

'ß' -> 223 -> 223 .chr does not work

---> how an I convert the two byte-numbers [195, 159] to the utf8-number
?
(or can this only be done by a lookup-table?)

thank you

Opt

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
  Matthew Kerwin
  https://matthew.kerwin.net.au/

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe> <ruby-talk-request@ruby-lang.org?subject=unsubscribe><http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt; <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--
  Matthew Kerwin
  https://matthew.kerwin.net.au/