LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-07-2011, 10:33 PM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
How to get a Unicode number?


Stupid, trivial question -- But what is the easiest way to figure out the Unicode number of a character when you already have the character?

For instance, I pasted this character here from a PDF:

Code:
 
Old 07-07-2011, 10:39 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hello,

Most distros will come with a character map-like program, just like in windows. I know that in Fedora, you go to Applications, Accessories, Character Map (or something else - I forget what it is called off the top of my head.) You could also use google and find a reference to a chart or something similar; Have a look here - http://www.ssec.wisc.edu/~tomw/java/unicode.html

Cheers,

Josh
 
Old 07-07-2011, 11:03 PM   #3
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
Figured it out...

Code:
# ghci
GHCi, version 7.0.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> "⊥"
"\8869"
Of course, you may need to convert that to hexadecimal.

Another alternative is to do what I did inadvertently, which is to post the character to this forum, and then look at the forum post HTML source, which will have converted the character to &#DDDD.
 
Old 07-08-2011, 11:15 AM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
There you go then
 
Old 07-09-2011, 10:47 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Install uniutils, which includes the uniname command.

Code:
$ echo -n "⊥" | uniname
character  byte       UTF-32   encoded as     glyph   name
        0          0  0022A5   E2 8A A5       ⊥      UP TACK
The UTF32 output is equal to the unicode codepoint, in hex (minus the leading zeroes).

Unfortunately uniname doesn't have an option to print only the UTF32/codepoint value, so you have to use awk or similar to extract it. Here are a couple of gawk one-liners that will print the code in hex and decimal form:

Code:
$ echo -n "⊥" | uniname -bcgnp | awk 'NR != 1 { gsub( /^0*/ ,"" , $1 ) ; print $1 }'
22A5
$ echo -n "⊥" | uniname -bcgnp | awk 'NR != 1 { gsub( /^0*/ ,"0x" , $1 ) ; print strtonum( $1 ) }'
8869
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP + MYSQL: Invalid parameter number: number of bound variables does not match... OrangeGrover Linux - Software 6 05-08-2013 05:36 PM
how to change the complex number display mode. ... real number sandeep002gupta Programming 1 05-09-2011 06:15 AM
Identify and explain the major number, minor number, and revision number in Linux... turbomen Linux - Newbie 1 11-16-2010 02:48 AM
adding constant (number) to a number in all rows skuz_ball Programming 2 05-20-2008 09:57 PM
why there is a need for minor number and major number for monitor/keyboard in pc? tripathi Solaris / OpenSolaris 1 11-07-2003 09:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration