New answers tagged

6

Someone might suggest a program. It is not a trivial problem to do well: "ANSI sequences" are standardized in ECMA-48, some of your examples (such as the cursor appearance and enter_ca_mode) are not in the standard, some such as the enter_ca_mode 1049 code have variations (\E7\E[?47h). If a program relies on a terminal description, only one of the ...


7

A pure bash version: #!/bin/bash number="$1" number=${number//۱/1} number=${number//۲/2} number=${number//۳/3} number=${number//۴/4} number=${number//۵/5} number=${number//۶/6} number=${number//۷/7} number=${number//۸/8} number=${number//۹/9} number=${number//۰/0} echo "Result is $number" Have tested in my Gentoo machine and it works. ./convert ۱۳۲ ...


3

Since iconv can't seem to grok this, the next port of call would be to use the tr utility: $ echo "۲۱" | tr '۰۱۲۳۴۵۶۷۸۹' '0123456789' 21 tr translates one set of characters to another, so we simply tell it to translate the set of Farsi digits to the set of Latin digits. EDIT: As user @cuonglm points out. This requires non-GNU tr, for example the tr on a ...


25

Since it's a fixed set of numbers, you can do it by hand: $ echo ۲۱ | LC_ALL=en_US.UTF-8 sed -e 'y/۰۱۲۳۴۵۶۷۸۹/0123456789/' 21 (or using tr, but not GNU tr yet) Setting your locale to en_US.utf8 (or better to the locale which characters set belongs to) is required for sed to recognize your characters set. With perl: $ echo "۲۱" | perl -CS -MUnicode::...


14

For Python there is the unidecode library which handles such conversions in general: https://pypi.python.org/pypi/Unidecode. In Python 2: >>> from unidecode import unidecode >>> unidecode(u"۰۱۲۳۴۵۶۷۸۹") '0123456789' In Python 3: >>> from unidecode import unidecode >>> unidecode("۰۱۲۳۴۵۶۷۸۹") '0123456789' The SO ...


0

Your procedure is correct. Your terminology could use small detail work though. You want to declare the second,new disk to be a member of a new degraded RAID1 array. Then boot with a liveCD, dd the Data over, and then declare the first,older disk to be a mirror of the above array. Depending on how exactly GRUB locates the RootFS, you may need to edit your ...


1

the -layer option of convert can optimize frames and often result in gifs with smaller sizes. this for example optimizes by reducing the number of pixels per frame: convert *.gif -layers optimize-frame animation.gif also the -colors option limits the maximum number of unique colors.



Top 50 recent answers are included