👤
Home Man
Search
Today's Posts
Register

OS X is a line of Unix-based graphical operating systems developed, marketed, and sold by Apple.

Unicode encoding and decoding, OSX 10.13.5.

👤 Login to reply

 
Thread Tools Search this Thread
# 1  
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_encoding-jpeg  
Unicode encoding and decoding, OSX 10.13.5.-ascii_encoding-jpeg  

# 2  
Old 06-25-2018
Occasionally it's useful to lie about what your terminal is, i.e. LC_ALL="en_GB.US-ASCII" grep filename whatever to speed up grep when you know it won't matter. But changing the environment variable does not change your terminal. The terminal doesn't even have any way to know you changed it, being you changed it in the shell, not any place it has access to.
The Following User Says Thank You to Corona688 For This Useful Post:
wisecracker (06-26-2018)
# 3  
Old 06-26-2018
Thanks Corona688...

I thought that changing LANG would change the DEncoding for code inside a script.
Changing the DEncoding via the Terminal Preferences works a treat but that defeats the object of something I was experimenting with.
Back to the drawing board... <wink>
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
View file encoding then change encoding. mrreds Solaris 2 01-13-2018 03:19 PM
ASN1 decoding error tahchiev01 Programming 0 04-07-2017 09:19 AM
Decoding and pattern matching nans Shell Programming and Scripting 1 08-22-2014 11:08 AM
FTP decoding Bhavesh Sharma Shell Programming and Scripting 5 06-25-2014 08:31 PM
Decoding a string pandeesh UNIX for Dummies Questions & Answers 18 03-19-2012 06:38 AM
URL decoding with awk uiop44 UNIX for Dummies Questions & Answers 2 03-01-2012 02:22 PM
How to find the file encoding and updating the file encoding? cnraja Shell Programming and Scripting 7 05-27-2011 06:50 AM
Packet decoding Breakology IP Networking 2 11-07-2010 09:38 PM
decoding commands rochitsharma Shell Programming and Scripting 8 05-29-2006 12:09 PM
How to display unicode characters / unicode string jackdorso Programming 3 05-20-2005 01:09 PM


All times are GMT -4. The time now is 08:11 PM.

Unix & Linux Forums Content Copyright1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password