Sponsored Content
Operating Systems OS X (Apple) Unicode encoding and decoding, OSX 10.13.5. Post 303019224 by wisecracker on Monday 25th of June 2018 01:00:48 PM
Old 06-25-2018
Unicode encoding and decoding, OSX 10.13.5.

I am struggling here to understand......
The default encoding.
See photo 1.
Why does this NOT work?
Code:
#!/bin/bash
# Code for OSX 10.13.5. default UNICODE encoding.
echo""
echo "The default UTF-8..."
locale
echo""
echo "Change to 8 bit ASCII only..."
LANG="en_GB.US-ASCII"
export LANG="en_GB.US-ASCII"
locale
echo ""
for N in {0..255}
do
	printf '\x'$( printf "%02x" "$N" )
done
echo ""

Runtime result:
Code:
Last login: Mon Jun 25 17:35:20 on ttys000
AMIGA:amiga~> cd ~/Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> ./Unicode_Locale.sh

The default UTF-8...
LANG="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_CTYPE="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_ALL=

Change to 8 bit ASCII only...
LANG="en_GB.US-ASCII"
LC_COLLATE="en_GB.US-ASCII"
LC_CTYPE="en_GB.US-ASCII"
LC_MESSAGES="en_GB.US-ASCII"
LC_MONETARY="en_GB.US-ASCII"
LC_NUMERIC="en_GB.US-ASCII"
LC_TIME="en_GB.US-ASCII"
LC_ALL=

	


!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
AMIGA:amiga~/Desktop/Code/Shell> _

Now change encoding from terminal preferences to Western ASCII.
See photo 2.
And voila it works.
Code:
#!/bin/bash
echo ""
echo "Default encoding changed to ~ASCII via terminal preferences..."
locale
echo""
for N in {0..255}
do
	printf '\x'$( printf "%02x" "$N" )
done
echo ""

Runtime result:
Code:
Last login: Mon Jun 25 17:42:33 on ttys000
AMIGA:amiga~> cd ~/Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> ./ASCII_Coding.sh

Default encoding changed to ~ASCII via terminal preferences...
LANG="en_GB.US-ASCII"
LC_COLLATE="en_GB.US-ASCII"
LC_CTYPE="en_GB.US-ASCII"
LC_MESSAGES="en_GB.US-ASCII"
LC_MONETARY="en_GB.US-ASCII"
LC_NUMERIC="en_GB.US-ASCII"
LC_TIME="en_GB.US-ASCII"
LC_ALL=

	


!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ**
AMIGA:amiga~/Desktop/Code/Shell> _

Am I missing something with the soft-coded locale change as opposed to the terminal startup one?
Unicode encoding and decoding, OSX 10.13.5.-default_encodingjpeg
Unicode encoding and decoding, OSX 10.13.5.-ascii_encodingjpeg
 

10 More Discussions You Might Find Interesting

1. Programming

Decoding of Core Dump

Hi ALL, Is it possible to decode the core dumb file to find the error? I get an Memory Core Dumb error with an core file. Regards, P. Prathaban. (3 Replies)
Discussion started by: p_prathaban
3 Replies

2. Programming

How to display unicode characters / unicode string

I have a stream of characters like "\u8BBE\u5907\u7BA1" and i want to display it. I tried following things already without any luck. 1) printf("%s",L("\u8BBE\u5907\u7BA1")); 2) printf("%lc",0x8BBE); 3) setlocale followed by fwide followed by wprintf 4) also changed the local manually... (3 Replies)
Discussion started by: jackdorso
3 Replies

3. Shell Programming and Scripting

decoding commands

hi please can anyone help me in decoding shell commands. i need a way to decode the encrypted shell commands. (8 Replies)
Discussion started by: rochitsharma
8 Replies

4. IP Networking

Packet decoding

Hi, wondering if anyone can suggest a tool to me that will let me either cut & paste hex or type it in for packet decoding. I want to be able to decode a packet as done with tcpdump or wireshark, but I want to be able to manually input the hex myself. (2 Replies)
Discussion started by: Breakology
2 Replies

5. Shell Programming and Scripting

How to find the file encoding and updating the file encoding?

Hi, I am beginner to Unix. My requirement is to validate the encoding used in the incoming file(csv,txt).If it is encoded with UTF-8 format,then the file should remain as such otherwise i need to chnage the encoding to UTF-8. Please advice me how to proceed on this. (7 Replies)
Discussion started by: cnraja
7 Replies

6. UNIX for Dummies Questions & Answers

URL decoding with awk

The challenge: Decode URL's, i.e. convert %HEX to the corresponding special characters, using only UNIX base utilities, and without having to type out each special character. I have an anonymous C code snippet where the author assigns each hex digit a number from 0 to 16 and then does some... (2 Replies)
Discussion started by: uiop44
2 Replies

7. UNIX for Dummies Questions & Answers

Decoding a string

Hi, If my input string is 3a3b4c then my result should be aaabbbcccc. Please guide me how to achieve this in a bash script. Thanks (18 Replies)
Discussion started by: pandeesh
18 Replies

8. Shell Programming and Scripting

FTP decoding

I am trying to understand a UNIX script which FTPs certain files from a remote location to the local machine. I understand the basic FTP command but the UNIX script uses the following command: ftp -n -i -v > $logftp_trg 2>&1 <<! open $MFX_FTP_SERVER user $MFX_FTP_LOGIN $MFX_FTP_PWD Can anyone... (5 Replies)
Discussion started by: Bhavesh Sharma
5 Replies

9. Programming

ASN1 decoding error

Hi, fellows i am modifying asn1 schema to be able to decode a file, but i am hitting a error on one of the fields using free online tool asn1-playground. I suspect i need to change type and have tried with IDENTIFIER but it doesn't help...any ideas check the schema and file down , please ... (0 Replies)
Discussion started by: tahchiev01
0 Replies

10. Solaris

View file encoding then change encoding.

Hi all!! Im using command file -i myfile.xml to validate XML file encoding, but it is just saying regular file . Im expecting / looking an output as UTF8 or ANSI / ASCII Is there command to display the files encoding? Thank you! (2 Replies)
Discussion started by: mrreds
2 Replies
All times are GMT -4. The time now is 01:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy