Dark Bit Factory & Gravity

PROGRAMMING => C / C++ /C# => Topic started by: Pixel_Outlaw on June 13, 2011

Title: [C++] outputting unicode strings...
Post by: Pixel_Outlaw on June 13, 2011

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.

Title: Re: [C++] outputting unicode strings...
Post by: hellfire on June 13, 2011
Like this (http://blog.kalmbachnet.de/?postid=98) ?
Title: Re: [C++] outputting unicode strings...
Post by: Pixel_Outlaw on June 13, 2011
I'm using GCC\Linux and it looks like that code may not be compatible.

Resulting debug:
Code: [Select]
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 ===|

Title: Re: [C++] outputting unicode strings...
Post by: Jim on June 14, 2011
Correct, that code is for Microsoft C runtime only.
Title: Re: [C++] outputting unicode strings...
Post by: Jim on June 15, 2011
Code: [Select]
#include <stdio.h>
int main(void)
{
printf("%lc", 0x280F);
return 0;
}
Does this work?

Jim
Title: Re: [C++] outputting unicode strings...
Post by: Pixel_Outlaw on June 15, 2011
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.
Title: Re: [C++] outputting unicode strings...
Post by: Jim on June 15, 2011
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

Title: Re: [C++] outputting unicode strings...
Post by: Pixel_Outlaw on June 15, 2011
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.

Code: [Select]

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

Title: Re: [C++] outputting unicode strings...
Post by: Pixel_Outlaw on June 20, 2011
Hmm I can output a block character from unicode directly with my compiler:

Code: [Select]
cout << "▒" << endl;

However I have a feeling that this is not portable nor standard usage...
Title: Re: [C++] outputting unicode strings...
Post by: Jim on June 20, 2011
Does this help?
http://mielke.cc/pipermail/brltty/2008-January/003239.html (http://mielke.cc/pipermail/brltty/2008-January/003239.html)

Jim
Title: Re: [C++] outputting unicode strings...
Post by: Pixel_Outlaw on June 21, 2011

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.