From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Convert the hexadecimal character code to the corresponding Unicode value. Date: Fri, 1 Oct 2021 21:14:04 +0800 Message-ID: References: <87ilyhgh66.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40579"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 01 15:18:53 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mWIRA-000AQP-Rk for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 01 Oct 2021 15:18:52 +0200 Original-Received: from localhost ([::1]:41450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWIR9-0007cU-Ow for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 01 Oct 2021 09:18:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWIMk-0003fp-PV for help-gnu-emacs@gnu.org; Fri, 01 Oct 2021 09:14:19 -0400 Original-Received: from mail-vs1-xe33.google.com ([2607:f8b0:4864:20::e33]:38703) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWIMi-0001S6-TP for help-gnu-emacs@gnu.org; Fri, 01 Oct 2021 09:14:18 -0400 Original-Received: by mail-vs1-xe33.google.com with SMTP id y141so11243100vsy.5 for ; Fri, 01 Oct 2021 06:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=BInIqbBC+ElvHjtsz56c5g7bQilYT9r0IYgbpPmOpMg=; b=A2ymyUbKu4J3Z3cPyGmeb2OMe1Y0eluRwWAIADrIdqom8YiPgPtVyM8XPhaEFo561/ 8xccaadiL1h9iIpC/KbM1a+XKWUegSBbT+VvAiLRlgSfQpsWM0aZL+0A9fzZ6YavlgY3 yGHDO4gB8qi1Le1ErsiApeFD3ervf0RnqlaAjErIH+DCuQ5M/EEGoU4T54kreop1B3lY dv3PLt380gq4fwRKAv8GKyh0DBgOHf3+grdS5+ITsCkVfsLZYCckFstUYuGnxQCwMu2o tp067be7O/tbaIK4Vbcy7tHHujR8kT20++wd3QOFrKZGsR7GNHBENJLStHYQKHI/99ii oPOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=BInIqbBC+ElvHjtsz56c5g7bQilYT9r0IYgbpPmOpMg=; b=pveigV0AW/c/bF4N+jhtXw6b/7H4hGN1l9VKk3RCLhVkANGZYJwUkV1USnfJjswCGG ef7b7nCrt0jZ5zf8C6EIiZ00TZqkpuTJ3Kc/Yy56S4hQqTJhY99cUSB+Vq8Xh9wbJqt2 lucXSXG2bnSHdKbkd4VilvZ8+8FYdroiTX7TUd9DW5L+FmQBOoQ/7ZH5aBVb5RdPq6X8 zinXUZw23IU2xLzGovZ+4BKBcsr3TnLbW7MDSJAe0+M5lz+HUEJ1rfxvP093j/Zyugpn exSVvx1x3QSyGL4DKloSoWizxgLzVsBAcna5Yxwl5BE4VWsKr3NVOyCLR5Ou4/9wSrVN HSSQ== X-Gm-Message-State: AOAM530nOFokqYKdQhf1Pnha0wGGkpUTa1AEb4vBuYJ02kcLxV5NWmPf skB3cfSFDwtZPFLFWV8nEKL1Y0seAM1BUs0eQhLMZdeBJjsJNxfu X-Google-Smtp-Source: ABdhPJxaNO/D5e7PVHuG+zs3jLVXYLs47CclwmDK6pVp+d6equrhvRRrK1jC7ACYDQ8oK9Mw+xBWNF9gv0eFcwzswaU= X-Received: by 2002:a05:6102:1357:: with SMTP id j23mr3830100vsl.25.1633094055732; Fri, 01 Oct 2021 06:14:15 -0700 (PDT) In-Reply-To: <87ilyhgh66.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::e33; envelope-from=hongyi.zhao@gmail.com; helo=mail-vs1-xe33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:133488 Archived-At: On Fri, Oct 1, 2021 at 6:42 PM Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > Hongyi Zhao wrote: > > > I noticed some comments on the escape syntax used by Emacs > > from here [1-2]. By default, the `describe-char' command > > will give the code point representation of the character in > > hexadecimal and octal formats, say, #o240, #xa0. So, I want > > to if there is a convenient way to do the conversion between > > the hexadecimal character code representation and the > > corresponding Unicode value. > > Leads us to the greatest of all human aspirations: > > https://www.youtube.com/watch?v=xA6DtpRuvSQ > > Convert between bases: > > #! /bin/zsh > # > # this file: > # http://user.it.uu.se/~embe8573/conf/.zsh/math > # https://dataswamp.org/~incal/conf/.zsh/math > # > # [...] > > change-base () { > local from=$1 > local to=$2 > > local value=$3 > > echo "obase=$to; ibase=$from; $value" | bc > } > > # _16 -> > hex2dec () { change-base 16 10 $1 } > hex2oct () { change-base 16 8 $1 } > hex2bin () { change-base 16 2 $1 } > > # _10 -> > dec2hex () { > local dec=$1 > local res > res=$(change-base 10 16 $dec) > echo $res:l > } > dec2oct () { change-base 10 8 $1 } > dec2bin () { change-base 10 2 $1 } > > # _8 -> > oct2hex () { > local oct=$1 > local res > res=$(change-base 8 16 $oct) > echo $res:l > } > oct2dec () { change-base 8 10 $1 } > oct2bin () { change-base 8 2 $1 } > > # _2 -> > bin2hex () { > local bin=$1 > local res > res=$(change-base 2 16 $bin) > echo $res:l > } > bin2dec () { change-base 2 10 $1 } > bin2oct () { change-base 2 8 $1 } See this project which can do base conversion up to 36 easily in Emacs: https://github.com/AdamNiederer/0xc But sorry for my inaccurate description. I mean the "\uxxxx" or "\U00xxxxxx" counterpart of the code point represented by decimal/hexadecimal/octal formats. So the shell script you posted above is not exactly what I asked. BTW, why do you use `incar' as your website's main name [1]? [1] https://dataswamp.org/~incal HZ