• Re: using Unicode codepoints in a bash script

    From Qruqs@21:1/5 to All on Sun Aug 18 08:04:28 2024
    On Wed, 29 Nov 2023 00:01:06 -0800 (PST), paris2venice wrote:

    bash --version GNU bash, version 3.2.57(1)-release
    (x86_64-apple-darwin20)
    Copyright (C) 2007 Free Software Foundation, Inc.

    Like many already said Bash version might be an issue, I use:

    $ bash --version
    GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu)
    Copyright (C) 2022 Free Software Foundation, Inc.

    Plus, I don't know if there is anyone still around to even bother about my posting this (seems it went dead after that stupid googlegroups was turned
    off, finally! "do no harm", right...), and I also know this isn't a Python group, but anyhoo, since it's more or less dead anyway...

    Is there a reason it _has_ to be Bash?

    You could try another language. Python for instance, can also be run like
    an executable text file, just like a shell script. You can also call other scripts from Python, for example running the stuff that is easier to do in Python and when it's done call some other script and have it have a go at solving the rest. You can also use the "sys" module and use pipes into
    your Python script and it can send its result out via stdout. Your
    imagination is the limit here.

    Python 3.12: test-hieroglyphs-post-20240818.py

    CODE:
    ---8<-------------------------------------------------------------------
    #! /usr/bin/env python3
    #coding: utf-8
    print("As is:", "ð“€€")
    print("Using character names:", chr(ord('\N{EGYPTIAN HIEROGLYPH A001}'))) print("The code points as hex:", "ð“€€".encode('utf-8')) ---8<-------------------------------------------------------------------

    Running it:
    $ ./test-hieroglyphs-post-20240818.py
    As is: ð“€€
    Using character names: ð“€€
    The code points as hex bytes: b'\xf0\x93\x80\x80'


    This works because Python 3.x is Unicode aware. All strings are Unicode by default.

    There are other languages that might be suitable also. Pick one and try it
    out.


    There are more ways than one to skin a cat.

    Q.
    --
    Currently using: https://manjaro.org/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)