Sponsored Content
Special Forums Windows & DOS: Issues & Discussions Convert "hex" foldername to "ascii" Post 303038500 by wisecracker on Wednesday 4th of September 2019 03:22:56 PM
Old 09-04-2019
To do this task is not trivial in CMD.EXE, I don't know about PowerShell.
(Boy oh boy, the last time I did a '.BAT' file was in 2013 in AudioScope.sh.)

Here is the method used in CMD.EXE translated to UNIX.
Inside the code are the two main batchfile lines to do the task from decimal to character.
Code:
#!/usr/local/bin/dash
# Quick and dirty convert hex to char to demonstrate the Windows CMD.EXE method.

# Hex value '0x41' is 'A'.
HEXVAL="41"
DECIVAL=$( printf "%d" "0x${HEXVAL}" )
/usr/local/bin/dash -c "exit ${DECIVAL}"
RC=$?
CHAR=$( printf \\$( printf "%o" "${RC}" ) )
echo "${CHAR}"

# REM Windows CMD.EXE "terminal", (might even work in COMMAND.COM for 32 bit Windows).
# REM A starter to get a quick and dirty ASCII character from decimal.
# REM Converting hex to decimal is just a couple of lines away.
# REM Looping through each hex pair should be easy.
#
# CMD.EXE /C EXIT 65
# ECHO %=exitcodeAscii%

Result of the demo, OSX 10.14.3, default bash terminal calling 'dash'.
Code:
Last login: Wed Sep  4 20:04:57 on ttys000
AMIGA:amiga~> cd Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> ./hex_char.sh
A
AMIGA:amiga~/Desktop/Code/Shell> _

(I have actually used the RC method for peeking memory on the AMIGA in Python.)
Have fun...
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

why "iconv" didn't convert myfile.csv to ASCII?

(it seems that this post is best put here, where shell programming people use "iconv" and "file" all the time. it was posted in the Linux Application and got no replies) Dear there, I tried to use iconv to convert myfile.csv to ASCII and failed. Any ideas? myfile.csv contains only ASCII... (2 Replies)
Discussion started by: patiobarbecue
2 Replies

3. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

6. Solaris

The slices "usr", "opt", "tmp" disappeared!!! Help please.

The system don't boot. on the screen appears following: press enter to maintenance (or type CTRL-D to continue)...I checked with format command. ... the slices "0-root","1-swap","2-backup" exist. ...the slises "3-var","6-usr" -unassigned. :( (16 Replies)
Discussion started by: wolfgang
16 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

9. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies
jiskanji(5)							File Formats Manual						       jiskanji(5)

NAME
jiskanji, jiskanji7, JIS7 - A character encoding system (codeset) for Japanese DESCRIPTION
JIS Kanji is a codeset that uses the JIS X0202 symbol extension method for encoding the JIS X0208 and JIS X0201 character sets. There are two types of JIS Kanji encoding: 7-bit JIS Kanji code and 8-bit JIS Kanji code. 7-bit JIS Kanji Code In 7-bit JIS Kanji encoding, all character values are 7-bit bytes. Characters are interpreted according to preceding in and out sequences as follows: Kanji in sequence (ESC $ B) The code values following the Kanji in sequence (ESC $ B) are treated as characters in the JIS X0208 Kanji character set. Kanji out sequence (ESC ( B) The code values following the Kanji out sequence (ESC ( B) are treated as ASCII characters. Supplementary Kanji in sequence (ESC $ ( D) The code values following the supplementary Kanji in sequence (ESC $ ( D) are treated as characters in the JIS X0212 supplementary Kanji character set. User-Defined Character (UDC) in sequence (ESC $ ( 0) The code values following the UDC in sequence (ESC $ ( 0) are treated as characters in the vendor-defined or user-defined character set. Kana in (SO) and Kana out (SI) sequences The code values following SO(0x0e) and preceding SI(0x0f) are treated as characters in the JIS X0201 Katakana character set. Katakana in sequence (ESC ( I) Code values following the Katakana in sequence (ESC ( I) are treated as characters in the JIS X0201 Katakana character set. In this case, the Kanji out sequence is used to switch back to ASCII code. The Katakana in and Kanji out sequences are an alternative to using the Kana in and out sequences (SO/SI). 8-bit JIS Kanji Code In 8-bit JIS Kanji encoding, the JIS X0201 Katakana characters are represented as 8-bit bytes. Using this form of encoding, in and out sequences have the following effect: Kanji in sequence (ESC $ B) Code values following the Kanji in sequence (ESC $ B) are treated as characters in the JIS X0208 Kanji character set. Supplementary Kanji in sequence (ESC $ ( D) Code values following the supplementary Kanji in sequence (ESC $ ( D) are treated as characters in the JIS X0212 supplementary Kanji character set. User-Defined Character (UDC) in sequence (ESC $ ( 0) Code values following the UDC in sequence (ESC $ ( 0) are treated as vendor-defined or user-defined characters. Kanji out sequence (ESC ( B) Code values following the Kanji out sequence (ESC ( B) are treated as ASCII characters. Kana in and out sequences (SI/SO) These sequences are ignored. Codeset Conversion The following codeset converter pairs are available for converting Japanese characters between jiskanji7 or JIS7 and other encoding for- mats. The RESTRICTIONS section discusses some conversion limitations that apply to these converters. Refer to iconv_intro(5) for an introduction to codeset conversion. For more information about the other codeset for which jiskanji7 or JIS7 is the input or output, see the reference page specified in the list item. deckanji_jiskanji7 or deckanji_JIS7, jiskanji7_deckanji or JIS7_deckanji Converting from and to the DEC Kanji codeset: deckanji(5). eucJP_jiskanji7 or eucJP_JIS7, jiskanji7_eucJP or JIS7_eucJP Converting from and to Japanese Extended UNIX Code: eucJP(5). eucTW_jiskanji7 or eucTW_JIS7, jiskanji7_eucTW or JIS7_eucTW Converting from and to Taiwanese Extended UNIX Code: eucTW(5). sdeckanji_jiskanji7 or sdeckanji_JIS7, jiskanji7_sdeckanji or JIS7_sdeckanji Converting from and to the Super DEC Kanji codeset: sdeckanji(5). SJIS_jiskanji7 or SJIS_JIS7, jiskanji7_SJIS or JIS7_SJIS Converting from and to Shift JIS format: SJIS(5). Shift JIS encoding format is identical to encoding in Microsoft code-pages used on PC systems. Therefore, you can use these convert- ers to convert Japanese characters between JIS Kanji and PC code-page format. For general information on how the operating system supports PC code pages, see code_page(5). RESTRICTIONS
The JIS Kanji codeset is not supported directly by a locale but through code conversion (through the iconv utility, Japanese terminal (tty) code conversion, and so forth). In the codeset naming conventions used by the iconv utility, the string JIS7 indicates 7-bit JIS Kanji code that follows a Katakana in sequence and the string jiskanji7 indicates 7-bit JIS Kanji code entered between Kana in and out sequences. The following sequences are valid for input to the iconv utility but are not generated when code is converted to jiskanji7: Kanji in (ESC $ @) Kanji in (ESC & @ ESC $ B) Kanji in (ESC $ ( B) Kanji in (ESC $ ( @) Supplementary Kanji in (ESC $ D) Kana in (ESC ( J) Kana in (ESC ( H) In the code naming conventions of the Japanese terminal, the string jis7 indicates 7-bit JIS Kanji code and the string jis8 indicates 8-bit JIS Kanji code. When the terminal code is set to jis7, the Kana in and out sequences (SI/SO) are used for JIS X0201 Katakana character rep- resentation. SEE ALSO
Commands: locale(1) Others: ascii(5), code_page(5), deckanji(5), eucJP(5), i18n_intro(5), i18n_printing(5), iconv_intro(5), iso2022jp(5), Japanese(5), l10n_intro(5), sdeckanji(5), shiftjis(5) jiskanji(5)
All times are GMT -4. The time now is 11:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy