Groups | Search | Server Info | Login | Register


Groups > de.comp.os.unix.shell > #14657

Re: System und Shell-Scripte: Latin-1 zu UTF-8

From Helmut Waitzmann <nn.throttle@erine.email>
Newsgroups de.comp.os.unix.shell
Subject Re: System und Shell-Scripte: Latin-1 zu UTF-8
Date 2026-03-08 03:40 +0100
Organization A noiseless patient Spider
Message-ID <83fr6b11ti.fsf@helmutwaitzmann.news.arcor.de> (permalink)
References <g0ht7m-qer.ln1@tempo.martinkl.dialup.fu-berlin.de> <87ms0jqp7f.fsf@s-bot.de> <1ppu7m-b4u.ln1@tempo.martinkl.dialup.fu-berlin.de>

Show all headers | View raw


 Martin Klaiber <usenet.martinkl@gmx.de>:
> Stefan Wiens <s.wi@gmx.net> wrote:
>
>> Abgesehen vom Konvertieren der Skripte 
>> mittels iconv sollte man auch darauf 
>> achten, dass sämtliche dort verwendeten 
>> Tools UTF-8-kompatibel sind und auf die 
>> locale, insbesondere LC_CTYPE adäquat 
>> reagieren. 
>
> Ja, danke, guter Tipp! 
>
> Denkst Du an ein bestimmtes Szenario? 
>
> Ich habe jetzt schon das "Problem", dass printf das Komma als 
> Dezimaltrennzeichen bei einer deutschen locale kennt, aber bc nicht, 
> sondern nur den Punkt. 
>
> Ich meine so etwas wie: 
>
> | martinkl@maurice:~$ printf "%f\n" $(echo "4/3" | bc -l)
> | -bash: printf: 1.33333333333333333333: invalid number
> | 1,000000
>
> Ich muss immer LC_NUMERIC=C setzen, damit printf den Dezimalpunkt 
> akzeptiert: 
>
> | martinkl@maurice:~$ LC_NUMERIC=C printf "%f\n" $(echo "4/3" | bc -l)
> | 1.333333
>

 Das Stand‐alone‐„printf“ akzeptiert in einem Locale mit 
 Dezimalkomma sowohl den Punkt als auch das Komma als 
 Dezimaltrenner.  Hier im Vergleich zu den in die Shells 
 eingebauten „printf“‐Kommandos: 


   (
     for commandline in \
       'bash-built-in bash -c '\''"$@"'\'' bash' \
       'sh-built-in sh -c '\''"$@"'\'' sh' \
       'dash-built-in dash -c '\''"$@"'\'' dash' \
       'stand-alone env'
     do
       eval 'set -- '"$commandline" &&
       printf '\n%s:\n' "$1 printf" &&
       shift &&
       "$@" printf '%f\n' '12.34' '12,34'
     done
   )


 ohne LC_NUMERIC auf C zu setzen.  (Bei mir ist „/bin/sh“ ein 
 symbolic link auf „bash“.) 


 Die Ausgabe sieht so aus: 


   bash-built-in printf:
   bash: line 1: printf: 12.34: invalid number
   12,000000
   12,340000

   sh-built-in printf:
   sh: line 1: printf: 12.34: invalid number
   12,000000
   12,340000

   dash-built-in printf:
   dash: 1: printf: 12,34: not completely converted
   12.340000
   12.000000

   stand-alone printf:
   12,340000
   12,340000


 Alternativ könnte man auch die Ausgabe von „bc“ durch „tr“ 
 schieben, um jegliche Punkte durch Kommata zu ersetzen: 


   printf '%s\n' '4/3' | bc -l |
   (
     dezimaltrenner="$( locale -- decimal_point )" &&
     tr -- . "$dezimaltrenner"
   )

Back to de.comp.os.unix.shell | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

System und Shell-Scripte: Latin-1 zu UTF-8 Martin Klaiber <usenet.martinkl@gmx.de> - 2026-03-07 13:07 +0100
  Re: System und Shell-Scripte: Latin-1 zu UTF-8 Tim Ritberg <tim@server.invalid> - 2026-03-07 13:17 +0100
    Re: System und Shell-Scripte: Latin-1 zu UTF-8 Martin Klaiber <usenet.martinkl@gmx.de> - 2026-03-07 16:34 +0100
  Re: System und Shell-Scripte: Latin-1 zu UTF-8 Ralph Aichinger <ra@h5.or.at> - 2026-03-07 12:35 +0000
    Re: System und Shell-Scripte: Latin-1 zu UTF-8 Martin Klaiber <usenet.martinkl@gmx.de> - 2026-03-07 16:33 +0100
  Re: System und Shell-Scripte: Latin-1 zu UTF-8 Thomas Hochstein <thh@thh.name> - 2026-03-07 14:04 +0100
    Re: System und Shell-Scripte: Latin-1 zu UTF-8 Urs Janßen <urs@niko.tin.org> - 2026-03-07 15:36 +0000
      Re: System und Shell-Scripte: Latin-1 zu UTF-8 ram@zedat.fu-berlin.de (Stefan Ram) - 2026-03-07 16:38 +0000
        Re: System und Shell-Scripte: Latin-1 zu UTF-8 ram@zedat.fu-berlin.de (Stefan Ram) - 2026-03-07 16:48 +0000
        Re: System und Shell-Scripte: Latin-1 zu UTF-8 Urs Janßen <urs@niko.tin.org> - 2026-03-07 16:51 +0000
      Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2026-03-07 20:02 +0000
        Re: System und Shell-Scripte: Latin-1 zu UTF-8 Urs Janßen <urs@niko.tin.org> - 2026-03-07 20:45 +0000
        Re: System und Shell-Scripte: Latin-1 zu UTF-8 Urs Janßen <urs@niko.tin.org> - 2026-03-07 20:50 +0000
        Re: System und Shell-Scripte: Latin-1 zu UTF-8 Helmut Waitzmann <nn.throttle@erine.email> - 2026-03-08 01:25 +0100
    Re: System und Shell-Scripte: Latin-1 zu UTF-8 Martin Klaiber <usenet.martinkl@gmx.de> - 2026-03-07 16:29 +0100
  Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-07 23:12 +0100
    Re: System und Shell-Scripte: Latin-1 zu UTF-8 Martin Klaiber <usenet.martinkl@gmx.de> - 2026-03-08 00:42 +0100
      Re: System und Shell-Scripte: Latin-1 zu UTF-8 Helmut Waitzmann <nn.throttle@erine.email> - 2026-03-08 03:40 +0100
        Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 06:14 +0100
          Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 10:47 +0100
          Re: System und Shell-Scripte: Latin-1 zu UTF-8 Helmut Waitzmann <nn.throttle@erine.email> - 2026-03-08 19:05 +0100
            Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 20:40 +0100
              Re: System und Shell-Scripte: Latin-1 zu UTF-8 Helmut Waitzmann <nn.throttle@erine.email> - 2026-03-08 22:29 +0100
                Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 23:27 +0100
      Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 09:36 +0100
  Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 07:17 +0100
    Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 09:56 +0100
      Re: System und Shell-Scripte: Latin-1 zu UTF-8 Ralph Aichinger <ra@h5.or.at> - 2026-03-08 09:11 +0000
        Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 10:19 +0100
          Re: System und Shell-Scripte: Latin-1 zu UTF-8 Ralph Aichinger <ra@h5.or.at> - 2026-03-08 10:25 +0000
            Re: System und Shell-Scripte: Latin-1 zu UTF-8 Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2026-03-08 10:41 +0000
            Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 11:52 +0100
  Re: System und Shell-Scripte: Latin-1 zu UTF-8 Hergen Lehmann <hlehmann-usenet26@snafu.de> - 2026-03-08 10:03 +0100
    Re: System und Shell-Scripte: Latin-1 zu UTF-8 Michael Bäuerle <michael.baeuerle@gmx.net> - 2026-03-08 10:56 +0100
      Re: System und Shell-Scripte: Latin-1 zu UTF-8 Stefan Wiens <s.wi@gmx.net> - 2026-03-08 11:19 +0100
        Re: System und Shell-Scripte: Latin-1 zu UTF-8 Michael Bäuerle <michael.baeuerle@gmx.net> - 2026-03-08 14:09 +0100

csiph-web