Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to generate a midline symbol from shell script

26 views
Skip to first unread message

Harry Putnam

unread,
Jan 18, 2012, 3:20:26 PM1/18/12
to
I'm having a little trouble googling up the details for this, possibly
using weak search strings, or at least the wrong ones.

How can I generate symbols from other languages perhaps, like the one
you sometimes see used as a `bullet';

(It appears like a small letter `o', smaller than usual and is
raised off the baseline to midline).

or a similar suitable character?

Something that works in console or text mode. Or in an xterm.

I seem to recall that one can manipulate a standard English keyboard
in some way to generate various characters.

Perhaps it can be scripted?

Janis Papanagnou

unread,
Jan 18, 2012, 3:46:52 PM1/18/12
to
On 18.01.2012 21:20, Harry Putnam wrote:
> I'm having a little trouble googling up the details for this, possibly
> using weak search strings, or at least the wrong ones.
>
> How can I generate symbols from other languages perhaps, like the one
> you sometimes see used as a `bullet';
>
> (It appears like a small letter `o', smaller than usual and is
> raised off the baseline to midline).

You mean the character for degree?

>
> or a similar suitable character?

I have that letter on the keyboard, so I just type or print it.

>
> Something that works in console or text mode. Or in an xterm.
>
> I seem to recall that one can manipulate a standard English keyboard
> in some way to generate various characters.

I seem to recall that there was a <Compose> key on an IBM keyboard,
where you could (while holding down that key) type in decimal numbers
from the number pad, where the decimal number was the code position
in the current "codepage".

>
> Perhaps it can be scripted?

Until we know more precisely what you want you may want to play/start
with this

awk 'BEGIN{for(i=160;i<=255;i++)printf("%c",i)}'


Janis

Kaz Kylheku

unread,
Jan 18, 2012, 4:01:06 PM1/18/12
to
On 2012-01-18, Harry Putnam <rea...@newsguy.com> wrote:
> I'm having a little trouble googling up the details for this, possibly
> using weak search strings, or at least the wrong ones.
>
> How can I generate symbols from other languages perhaps, like the one
> you sometimes see used as a `bullet';
>
> (It appears like a small letter `o', smaller than usual and is
> raised off the baseline to midline).
>
> or a similar suitable character?
>
> Something that works in console or text mode. Or in an xterm.

You need multilingual support in your console for anything of this sort to
work. For instance, if your terminal emulator understands UTF-8 encoding,
then you can just print the UTF-8 bytes.

What is the UTF-8 sequence for the HTML character &bull; ? We can use
my "txr" utility together with "od" to find this out, and get it in octal:

$ txr -c '@(bind x "&bull;")
@(filter :from_html x)'
x="•"

$ txr -c '@(bind x "&bull;")
@(filter :from_html x)' | od -to1
0000000 170 075 042 342 200 242 042 012
0000010

The quote characters are 042, so the sequence we want is 342 200 242 in
between. Now that we know the codes, we can use them:

$ printf "\342\200\242 an excellent point\n"
• an excellent point

> I seem to recall that one can manipulate a standard English keyboard
> in some way to generate various characters.

The input method for entering special characters, assuming there even is one,
is entirely system-specific. If all you want is to output the character, I
wouldn't waste my time learning how to input it.

In an UTF-8 environment like the one I'm using, if you find a character in your
browser that you wuold like to be able to use just cut it and paste it into the
terminal. E.g.

$ od -to1
[paste character here, then hit Enter and Ctrl-D]
[now take the octal codes]

For instance, let's try it with the chinese character 漢:

$ od -to1
漢 <-- I cut and pasted this from a web page, and hit Enter, Ctrl-D.
0000000 346 274 242 012 <-- now we have this output from od
0000004

012 is the linefeed, so 346 274 and 242 are the UTF-8 bytes.

Test:

$ printf "the 'kan' in 'kanji' is: \346\274\242\n"
the 'kan' in 'kanji' is: 漢

Cheers ...

Harry

unread,
Jan 18, 2012, 11:30:26 PM1/18/12
to
Harry Putnam wrote...

>How can I generate symbols from other languages perhaps, like the one
>you sometimes see used as a `bullet';
>
> (It appears like a small letter `o', smaller than usual and is
> raised off the baseline to midline).
>
>or a similar suitable character?

ascii -e

Ivan Shmakov

unread,
Jan 18, 2012, 11:32:01 PM1/18/12
to
>>>>> "HP" == Harry Putnam <rea...@newsguy.com> writes:

HP> I'm having a little trouble googling up the details for this,
HP> possibly using weak search strings, or at least the wrong ones.

HP> How can I generate symbols from other languages perhaps, like the
HP> one you sometimes see used as a `bullet';

HP> (It appears like a small letter `o', smaller than usual and is
HP> raised off the baseline to midline).

HP> or a similar suitable character?

Like one of the following?

$ printf '23 \u00b0C\n\u2022 A bullet.\n'
23 °C
• A bullet.
$

Note that for the shells having printf built in, one may have to
specify the external variant of explicitly as, e. g.,
/usr/bin/printf. The code above assumes GNU Coreutils' printf.

[…]

--
FSF associate member #7257

Harry Putnam

unread,
Jan 20, 2012, 10:20:04 AM1/20/12
to
Janis Papanagnou <janis_pa...@hotmail.com> writes:

> On 18.01.2012 21:20, Harry Putnam wrote:
>> I'm having a little trouble googling up the details for this, possibly
>> using weak search strings, or at least the wrong ones.
>>
>> How can I generate symbols from other languages perhaps, like the one
>> you sometimes see used as a `bullet';
>>
>> (It appears like a small letter `o', smaller than usual and is
>> raised off the baseline to midline).
>
> You mean the character for degree?

No, I described what I wanted poorly and showed a `o' as example but I
see now it is the solid dot some call a bullet. I think because it
actually appears near mid line, unlike the percent char which is at
the top as shown by the position of the dashs below (assuming this
survives mail handling):

•- bullet °- percent

> Until we know more precisely what you want you may want to play/start
> with this
>
> awk 'BEGIN{for(i=160;i<=255;i++)printf("%c",i)}'


Here LANG=en_US.UTF-8

Oddly, running your awk line here does not show anything but blank
spaces when run in an xterm. But if I copy/paste the output into this
message (an emacs-24 terminal) then you see the result below (possibly
the result of some setting in xterm?) (And again assuming this
survives mail handling):

����������������������������������������������������������������





Harry Putnam

unread,
Jan 20, 2012, 10:20:15 AM1/20/12
to
I don't really see any likely candidates in that bunch.

Harry Putnam

unread,
Jan 20, 2012, 10:20:31 AM1/20/12
to
Kaz Kylheku <k...@kylheku.com> writes:

> On 2012-01-18, Harry Putnam <rea...@newsguy.com> wrote:
>> I'm having a little trouble googling up the details for this, possibly
>> using weak search strings, or at least the wrong ones.
>>
>> How can I generate symbols from other languages perhaps, like the one
>> you sometimes see used as a `bullet';
>>
>> (It appears like a small letter `o', smaller than usual and is
>> raised off the baseline to midline).
>>
>> or a similar suitable character?
>>
>> Something that works in console or text mode. Or in an xterm.
>
> You need multilingual support in your console for anything of this sort to
> work. For instance, if your terminal emulator understands UTF-8 encoding,
> then you can just print the UTF-8 bytes.
>
> What is the UTF-8 sequence for the HTML character &bull; ? We can use
> my "txr" utility together with "od" to find this out, and get it in octal:

[...] (snipped great tutorial)

Thanks for the nifty walk thru. txr is handy and I've never really
noticed od before to speak of.

Thanks for adding to my tool chest and the brief tutorial.

Harry Putnam

unread,
Jan 20, 2012, 10:20:43 AM1/20/12
to
Ivan Shmakov <onei...@gmail.com> writes:

[...]

> Like one of the following?
>
> $ printf '23 \u00b0C\n\u2022 A bullet.\n'
> 23 °C
> • A bullet.
> $
>
> Note that for the shells having printf built in, one may have to
> specify the external variant of explicitly as, e. g.,
> /usr/bin/printf. The code above assumes GNU Coreutils' printf.
>
> […]

Thank you,

Yes, the bullet there is what I was after. I see something odd here.

,----
| /usr/bin/printf --version
|
| printf (GNU coreutils) 8.13
| Copyright (C) 2011 Free Software Foundation, Inc.
| License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
| This is free software: you are free to change and redistribute it.
| There is NO WARRANTY, to the extent permitted by law.
|
| Written by David MacKenzie.
`----


When I run the command you showed it prints the degree symbol ok,
but not the bullet... at least the bullet is not visible in the xterm
where I run the command.

(Note: Running real xterm here, not one of the wannabee's:
xterm -version
XTerm(276))

However the symbol is really there, because if I copy paste the output
from the terminal into this message as below, the bullet is now
visible:

/usr/bin/printf '23 \u00b0C\n\u2022 A bullet.\n'
23 °C
• A bullet.

Aragorn

unread,
Jan 20, 2012, 11:44:50 AM1/20/12
to
On Friday 20 January 2012 16:20, Harry Putnam conveyed the following to
comp.unix.shell...

> •- bullet °- percent
^

No, "degree". Percent is "%". ;-)

--
= Aragorn =
(registered GNU/Linux user #223157)

Ivan Shmakov

unread,
Jan 22, 2012, 12:36:10 AM1/22/12
to
>>>>> Harry Putnam <rea...@newsguy.com> writes:
>>>>> Ivan Shmakov <onei...@gmail.com> writes:

>> Like one of the following?

>> $ printf '23 \u00b0C\n\u2022 A bullet.\n'

[…]

> When I run the command you showed it prints the degree symbol ok, but
> not the bullet... at least the bullet is not visible in the xterm
> where I run the command.

[…]

> However the symbol is really there, because if I copy paste the
> output from the terminal into this message as below, the bullet is
> now visible:

It looks like an issue with the font being used. Note that
while ISO-8859-1 has the DEGREE SIGN symbol, it has no BULLET
one. Therefore, when using an ISO-8859-1 font (instead of an
ISO-10646-1 one), it won't be possible to draw a BULLET.

One may wish to try starting XTerm with $ uxterm (which is just
another configuration for XTerm) instead of $ xterm.

Harry Putnam

unread,
Jan 26, 2012, 5:34:58 PM1/26/12
to
Apparently that is not it. Using uxterm appears to make no
difference.

However starting an xterm like this:

xterm -fn -xos4-terminus-bold-r-normal--14-140-72-72-c-80-iso10646-1

Does allow or cause the bullet to show up.. thanks for the tip.
0 new messages