Solved Extended ASCII with jot(1)

Hello,

I use jot(1) very often to generate random passwords:

Code:
jot -s $'\t' -r -c 250 32 126 | rs -c$'\t' -g0 0 25
Very handy (the trick with the tabulation as a separator allows me to produce pwd with spaces in them).

I would like to extend the charset of those random passwords by adding accented letters and other "high" ASCII characters. jot(1) seems able to handle it:

Code:
$ jot -s " " -b à -c 5
à à à à à
But as soon as I give an ASCII range, it fails printing extended ASCII characters correctly:

Code:
jot -s " " -r -c 10 224 229
? ? ? ? ? ? } ? ? ?
Tested on FreeBSD 9.3-RELEASE.

Any idea?
 
Dear patpro,
the failed printing seems to be related to the properties of the display.
Code:
$ jot -s " " -r -c 10 224 229
� � � � � � � � � �
This gives nonsense in my xterm with UTF-8 locale, same as in your case.

Now with x11/luit which is a tool to provide an enviroment with different encoding.
Code:
$ luit -encoding 'ISO 8859-1' jot -s " " -r -c 10 224 229
ä à à â ä â á à â á
This gives what you expected.

Code:
$ jot -s " " -r -c 10 224 229 > tmp.txt
$ xxd tmp.txt
0000000: e320 e220 e320 e520 e120 e520 e520 e520  . . . . . . . .
0000010: e520 e40a  . ..
might show what has been generated at this run. The bytes 0x20 seem to be the white spaces.
The bytes 0xE* seem to be the special characters.
 
Damn! I've tried many encoding tricks but I surely missed 8859-1, can't understand why. Your post gives the hint I was needing to solve my problem. Now I just use iconv(1) to perform the conversion:
Code:
$ jot -s" " -r -c 10 224 229 | iconv -f ISO-8859-1 -t UTF-8
ã ä à å å ä â ã å å
Thanks
 
Back
Top