Code-point gluph representation

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Code-point gluph representation

Post by dkaip »

Suppose i must print to utf8 file a font character with code-point 100000 in decimal with no turn in hex.
How i can print that glyph?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Code-point gluph representation

Post by ONEEYEMAN »

Hi,
I presume you will need to read it at some point?
What is you OS/toolkit/wx version?
Do you have a locale installed that supports this symbol?

What did you tried already?

Thank you.
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Code-point gluph representation

Post by dkaip »

Linux Mint / wxWidgets 3 / gcc / CodeBlocks
I don't need locale, only glyph with codepoint 100000 in desimal, and no locale.
I have made this with c++ but only until U+FFFF char, that is 65535 in decimal.
But i want to save to file glyph 100000.
Can i with wxWidgets?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Code-point gluph representation

Post by ONEEYEMAN »

Hi,
Are you trying to save a file with this glyph?
Or you trying to log something?

In any case - you should be able to do that. I'm just not sure you will be able to verify what was saved...

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Code-point gluph representation

Post by doublemax »

Code: Select all

  wxString s( wxUniChar(100000) );
  wxFile f( "c:\\_unicode_test.txt", wxFile::write );
  f.Write( s, wxConvUTF8 );
  f.Close();
Use the source, Luke!
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Code-point gluph representation

Post by dkaip »

I am trying to save a file with this glyph.
Thanks very mush, i will try it...
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Code-point gluph representation

Post by dkaip »

Code: Select all

wxString s( wxUniChar(100000) );
  wxFile f( "c:\\_unicode_test.txt", wxFile::write );
  f.Write( s, wxConvUTF8 );
  f.Close();
Sorry don't works. File f have encoding ANSI, not UTF-8 that i can see gluph.
If i change enconding i cant see glyph.
I will check if i have something wrong...
Bellow code works fine until 65535, but i dont have other glyphs up to 65535.

Code: Select all

std::string UnicodeToUTF8(unsigned int codepoint)
{
    std::string out;

    if (codepoint <= 0x7f)
        out.append(1, static_cast<char>(codepoint));
    else if (codepoint <= 0x7ff)
    {
        out.append(1, static_cast<char>(0xc0 | ((codepoint >> 6) & 0x1f)));
        out.append(1, static_cast<char>(0x80 | (codepoint & 0x3f)));
    }
    else if (codepoint <= 0xffff)
    {
        out.append(1, static_cast<char>(0xe0 | ((codepoint >> 12) & 0x0f)));
        out.append(1, static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
        out.append(1, static_cast<char>(0x80 | (codepoint & 0x3f)));
    }
    else
    {
        out.append(1, static_cast<char>(0xf0 | ((codepoint >> 18) & 0x07)));
        out.append(1, static_cast<char>(0x80 | ((codepoint >> 12) & 0x3f)));
        out.append(1, static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
        out.append(1, static_cast<char>(0x80 | (codepoint & 0x3f)));
    }
    return out;
}
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Code-point gluph representation

Post by dkaip »

I just check glyph, is in codepoint 100000 ...
I cant see it.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Code-point gluph representation

Post by doublemax »

You also need a font that contains that character.

On my Windows system there isn't a single font that contains it:
http://www.fileformat.info/info/unicode ... ertest.htm
Use the source, Luke!
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Code-point gluph representation

Post by dkaip »

i have made a font with fonforge, full unicode with some glyphs to test.
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Code-point gluph representation

Post by dkaip »

I just checked and code have no problem, all codes.
Notepad plus-plus have the problem.
Copying to OO no problem all are ok.
Thanks.
Jim
Post Reply