• Welcome to Dark Bit Factory & Gravity.
 

[C++] outputting unicode strings...

Started by Pixel_Outlaw, June 13, 2011

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Pixel_Outlaw


I currently have the need to output some unicode characters into the console window.
I wish to output some braille characters like shown  here...
http://tlt.its.psu.edu/suggestions/international/bylanguage/braillechart.html

These will be dithering patterns in a crude image to text program.
Please help if you can.

Challenge Trophies Won:

hellfire

Challenge Trophies Won:

Pixel_Outlaw

I'm using GCC\Linux and it looks like that code may not be compatible.

Resulting debug:

C:\Users\ryan\Desktop\blarg_test\main.cpp||In function 'int main()':|
C:\Users\ryan\Desktop\blarg_test\main.cpp|8|error: 'WCHAR' was not declared in this scope|
C:\Users\ryan\Desktop\blarg_test\main.cpp|8|error: expected ';' before 'c'|
C:\Users\ryan\Desktop\blarg_test\main.cpp|9|error: 'c' was not declared in this scope|
||=== Build finished: 3 errors, 0 warnings ===|


Challenge Trophies Won:

Jim

Correct, that code is for Microsoft C runtime only.
Challenge Trophies Won:

Jim


#include <stdio.h>
int main(void)
{
printf("%lc", 0x280F);
return 0;
}

Does this work?

Jim
Challenge Trophies Won:

Pixel_Outlaw

Oddly enough I dont see any character printed from that code Jim.

I'm fairly sure Debian supports Unicode in the terminal but I see nothing printed out. It does not have any errors or exceptions when debugging either.  ???

I did try a few things before posting here but still came up empty handed.
Challenge Trophies Won:

Jim

Yes, your terminal probably supports unicode via utf-8 encoding, but the question is if your C runtime can spit them out properly.

How about:

printf("\x28\x0F");
or
printf("\x0F\x28");

Jim

Challenge Trophies Won:

Pixel_Outlaw

#7
That time I got something Jim.

The character (   was printed for both calls.

I did one character then called printf with the other.
You can see the output "((" then my command prompt returned.



#include <stdio.h>
int main(void)
{
     printf("\x28\x0F");
     printf("\x0F\x28");
     return 0;
}

Challenge Trophies Won:

Pixel_Outlaw

Hmm I can output a block character from unicode directly with my compiler:


cout << "▒" << endl;


However I have a feeling that this is not portable nor standard usage...
Challenge Trophies Won:

Jim

Challenge Trophies Won:

Pixel_Outlaw


Jim, thanks for the information.  Looks like I am running the correct kernel version. (2.6.32)

I've decided to just use standard cout calls with the braille character plopped directly into the editor.
I won't worry about a Windows port of my image viewer simply because most of the time Windows users use only the GUI.
Challenge Trophies Won: