943,682 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 924
  • C++ RSS
Dec 17th, 2008
0

Emdash

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Light Poster
karang is offline Offline
46 posts
since Jul 2008
Dec 17th, 2008
0

Re: Emdash

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.
C++ Syntax (Toggle Plain Text)
  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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,949 posts
since Aug 2005
Dec 18th, 2008
0

Re: Emdash

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
Reputation Points: 10
Solved Threads: 0
Light Poster
karang is offline Offline
46 posts
since Jul 2008
Dec 18th, 2008
0

Re: Emdash

Click to Expand / Collapse  Quote originally posted by karang ...
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.
c++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Lining Chart
Next Thread in C++ Forum Timeline: What kind of Jobs can you get knowing C++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC