Identifying Character in a Text String

  • Thread starter Montana DOJ Help Desk
  • Start date
M

Montana DOJ Help Desk

Word 2000

I have a string of text that contains an unknown character. I need to
identify the character code. I've done this before, so I know that it's
possible, but I'm drawing a complete blank on the command that I used, and I
haven't been able to find the information in Help.

Can someone show me how to get the character code of an unknown character?

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
 
J

Jean-Guy Marcil

Montana DOJ Help Desk was telling us:
Montana DOJ Help Desk nous racontait que :
Word 2000

I have a string of text that contains an unknown character. I need to
identify the character code. I've done this before, so I know that
it's possible, but I'm drawing a complete blank on the command that I
used, and I haven't been able to find the information in Help.

Can someone show me how to get the character code of an unknown
character?


Select one character on the page and try:
MyCharCode = Asc(Selection.Text)

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
K

Klaus Linke

Jean-Guy Marcil said:
Select one character on the page and try:
MyCharCode = Asc(Selection.Text)

Better use AscW.
Asc only works for the 200 or so most widely used characters, and returns the codes from the old Windows code page 1252, which
differs in some cases from the "real" (Unicode) codes.

Regards,
Klaus
 
J

Jean-Guy Marcil

Klaus Linke was telling us:
Klaus Linke nous racontait que :

Good to know!

Will AscW return the real Unicode number for the Wingding et all. sets (or
other inserted "symbols")?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
K

Klaus Linke

Will AscW return the real Unicode number for the Wingding et all.
sets (or other inserted "symbols")?

With regular fonts, you don't have much problems.
Each symbol has it's specific code, independent of the font.

Say 263A, Alt+X (or using the decimal code: Alt+9786) produces the Unicode character "white smiling face", or smiley (though most fonts may not contain that special symbol).
AscW(Selection.Text) used on that character will give you 9786,
Hex(AscW(Selection.Text)) will give you 263A.

But decorative fonts like the Wingdings font you have mentioned are problematic.
Word has no way to determine what symbols such a symbol font may contain.
Those symbols aren't even necessarily defined in the Unicode Standard.

So Word uses codes in the code page at U+F000 (decimal 61440) for them.

Take a "smiley" from Wingdings as an example,
-- It is produced by the "J" key
(which has hex code 4A, or decimal code 74)
-- corresponds to U+F04A (= F000+4A)
equals decimal 61514 (61440+74)

You can for example search for it with u+61514 in "Find what".
Or you can insert it in text using ChrW(61514) or ChrW(&HF04A) in a macro (or F04A, Alt+X, or Alt+61514, in text), and format it in "Wingdings" font.
Here you need both the code and the font to specify the character.

Regards,
Klaus
 
J

Jean-Guy Marcil

Klaus Linke was telling us:
Klaus Linke nous racontait que :
With regular fonts, you don't have much problems.
Each symbol has it's specific code, independent of the font.

Say 263A, Alt+X (or using the decimal code: Alt+9786) produces the
Unicode character "white smiling face", or smiley (though most fonts
may not contain that special symbol).
AscW(Selection.Text) used on that character will give you 9786,
Hex(AscW(Selection.Text)) will give you 263A.

But decorative fonts like the Wingdings font you have mentioned are
problematic.
Word has no way to determine what symbols such a symbol font may
contain.
Those symbols aren't even necessarily defined in the Unicode Standard.

So Word uses codes in the code page at U+F000 (decimal 61440) for
them.

Take a "smiley" from Wingdings as an example,
-- It is produced by the "J" key
(which has hex code 4A, or decimal code 74)
-- corresponds to U+F04A (= F000+4A)
equals decimal 61514 (61440+74)

You can for example search for it with u+61514 in "Find what".
Or you can insert it in text using ChrW(61514) or ChrW(&HF04A) in a
macro (or F04A, Alt+X, or Alt+61514, in text), and format it in
"Wingdings" font.
Here you need both the code and the font to specify the character.

Ouch!
Messy!

Thanks for taking the time!

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
M

Montana DOJ Help Desk

Thanks for the help! That's exactly what I needed. I was thinking that the
last time I did this, I used a variation of the Chr function, so I was
looking right past the Asc function, even though it is listed in the See
Also list under several topics that I had previously looked at in Help. I
just had this pre-conceived notion of where I was suppose to be looking, and
I just could not break out of that mindset.

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top