help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to read N bytes instead of N characters?


From: Koichi Murase
Subject: Re: How to read N bytes instead of N characters?
Date: Tue, 14 May 2024 06:01:44 +0900

2024年5月14日(火) 5:42 Peng Yu <pengyu.ut@gmail.com>:
> Which variable is the most appropriate to treat bytes as characters?
> (So that it doesn't have the least side effects irrelevant to my
> current goal.) Thanks.

The locale category affecting the character counting is LC_CTYPE.
However, if you set LC_CTYPE globally, it still affects the processing
of other parts because it is the general setting for the character
encoding. It is safer to set the locale only for `read' such as «
LC_ALL=C read -N 4 ... ». Also, if you use LC_CTYPE instead of LC_ALL,
you need to ensure empty LC_ALL.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]