Emdash

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2008
Posts: 46
Reputation: karang is an unknown quantity at this point 
Solved Threads: 0
karang karang is offline Offline
Light Poster

Emdash

 
0
  #1
Dec 17th, 2008
Hi

I have a value of emdash


First of all I want to know Is this — a unicode

If Yes How to convert unicode i.e. — into -- using code in VC++

Regards
Karan
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,448
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1475
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Emdash

 
0
  #2
Dec 17th, 2008
It is not UNICODE -- its just a character from a special font. If you print that out (see below) you will see that it has a decimal value of -105.
  1. int main()
  2. {
  3. char c = '—';
  4. cout << c << " " << (int)c << "\n";
  5. return 0;
  6. }

So in your program just check for a character whose ascii value is -105 and change it to --.

At least that's how it works on an American keyboard and Vista Home. Other keyboards might be different, I don't know.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 46
Reputation: karang is an unknown quantity at this point 
Solved Threads: 0
karang karang is offline Offline
Light Poster

Re: Emdash

 
0
  #3
Dec 18th, 2008
if I have a variable called text of type char* then

What should I write in VC++ so that it assigns emdash value in the variable text
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Emdash

 
0
  #4
Dec 18th, 2008
Originally Posted by karang View Post
if I have a variable called text of type char* then

What should I write in VC++ so that it assigns emdash value in the variable text
1. The emdash character has value '\x97' in most of Windows single-byte code pages (it's equal to -105 if char type is signed and 16*9+7 if it's unsigned). Look out! No emdash character in most of Windows so called OEM code pages. Alas, Windows console applications put/get OEM coded characters to/from its consoles, so you can't print this character or get it from the keyboard in console application (without some tricks, but it's the other story).
2. Type char* variable points to a single char or to an array of char, it does not contain any chars.
  1. const char* pemdash = "\x97";
  2. // Now *pemdash expression returns emdash character value
  3. // See #1 above...
  4. char emdash = '\x97'; // it's emdash in most of code pages...
Last edited by ArkM; Dec 18th, 2008 at 2:38 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC