Print special characters[?]

Print special characters[?]

Post by RatkinHHK on Sat Apr 25, 2015 7:45 pm
([msg=87812]see Print special characters[?][/msg])

For example, the german language has special characters. So does my native language. I am talking about umlauts, the strange c with a cedile in french and the weird s in german... How do I write such a character in a text file, in C?

I know it has to do with character sets, but how do I set it in the code?
Any direction towards a tutorial is welcome. I cold not find any decent one...
Thanks is advance!
"You have enemies? Good. That means you've stood up for something, sometime in your life." --- Winston Churchill
User avatar
RatkinHHK
Experienced User
Experienced User
 
Posts: 72
Joined: Tue Nov 11, 2014 6:06 pm
Blog: View Blog (0)


Re: Print special characters[?]

Post by tremor77 on Sat Apr 25, 2015 9:18 pm
([msg=87815]see Re: Print special characters[?][/msg])

You need to probably set to UNICODE and use wprintf(), and then use the UNICODE character table to locate the code for the characters you want. http://unicode-table.com/en/#control-character
Image
User avatar
tremor77
Addict
Addict
 
Posts: 1097
Joined: Wed Mar 31, 2010 12:00 pm
Location: New York
Blog: View Blog (0)


Re: Print special characters[?]

Post by ghost107 on Sun Apr 26, 2015 2:25 am
([msg=87817]see Re: Print special characters[?][/msg])

Also you should look into wstring.h library, and use wchar_t instead of char, also to convert strings from multibyte into uncode or the other way around use mbstowcs and wcstombs
User avatar
ghost107
Poster
Poster
 
Posts: 321
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)


Re: Print special characters[?]

Post by RatkinHHK on Sun Apr 26, 2015 4:47 am
([msg=87818]see Re: Print special characters[?][/msg])

Well, I can't make it work.
How do I set the encoding to UNICODE?
And after:
Code: Select all
wchar_t c;


.. And making c equal to all sorts of things, I cannot print anything except '?'/'c'/'3'...etc

I tried:
Code: Select all
[b]c = L'ă';
c = 'U+0103';
c = 0103;[/b]
"You have enemies? Good. That means you've stood up for something, sometime in your life." --- Winston Churchill
User avatar
RatkinHHK
Experienced User
Experienced User
 
Posts: 72
Joined: Tue Nov 11, 2014 6:06 pm
Blog: View Blog (0)


Re: Print special characters[?]

Post by ghost107 on Mon Apr 27, 2015 1:05 pm
([msg=87828]see Re: Print special characters[?][/msg])

if you're using windows and writing in console window, you need to the console to support unicode, or set your operating system locale to your language:

RatkinHHK wrote:.. And making c equal to all sorts of things, I cannot print anything except '?'/'c'/'3'...etc

I tried:

Code: Select all
[b]c = L'ă';
    c = 'U+0103';
    c = 0103;[/b]

- c = L'ă'; should work,
- c = 0103; (the value is c) you're character is in hexadecimal so it would be c = 0x103; in decimal the value is c = 259;
- c = 'U+0103'; - I don't think this will work
User avatar
ghost107
Poster
Poster
 
Posts: 321
Joined: Wed Jul 02, 2008 7:57 am
Blog: View Blog (0)



Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests