- Subject: Re: [slang-users] printf - bug?
- From: "John E. Davis" <jed@xxxxxxxxxxx>
- Date: Mon, 28 Sep 2026 16:39:42 -0400
Bernd Eggink <be@xxxxxxxxxx> wrote:
> () = printf("%3s\n", "ä");
>
> The output on the screen is only 2 characters wide (the German “a” with
> an umlaut is on the right). Shouldn't `printf` count characters instead
> of bytes?
The underlying code uses the C printf family of functions. These use
byte semantics. I know that this is not the answer you were looking
for, but here is a work-around:
define printf_padded (str, width)
{
width += strbytelen(str)-strlen(str);
() = printf("%*s", width, str);
}
printf_padded ("ä", 3);
Thanks,
--John
>
> Best regards,
> Bernd
>
> --
> http://sudrala.de
>
> _______________________________________________
> For list information, visit <http://jedsoft.org/slang/mailinglists.html>.
>
_______________________________________________
For list information, visit <http://jedsoft.org/slang/mailinglists.html>.
[2026 date index]
[2026 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]