[Solved] UTF-8 Files and CEGUI::String

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
Ceacy
Just popping in
Just popping in
Posts: 16
Joined: Sun May 22, 2005 20:28
Location: France, Paris.
Contact:

[Solved] UTF-8 Files and CEGUI::String

Postby Ceacy » Sun May 22, 2005 20:32

Hello,
I have a problem with files containing UTF-8 encoded text and CEGUI : as i have to use std::ifstream and std;;string, I lose all accentuated characters ...

Code: Select all

std::ifstream fTextIntro( "intro_text.txt" );
   CEGUI::String strTextIntro;
   std::string strLine;
   if( fTextIntro )
   {
      while( std::getline( fTextIntro, strLine ) )
      {
         strTextIntro += strLine;
         strTextIntro += '\n';
      }
   }

   CEGUI::MultiLineEditbox* editbox = dynamic_cast<CEGUI::MultiLineEditbox*>( mSheet->getChild( (CEGUI::utf8*) "TextIntro" ) );
      editbox->setText( strTextIntro );


I also tried with std::wifstream and std::wstring, but there it seems to be not way to convert wifstream to CEGUI::String ... so i have no ideas any more :oops:

If someone could help me ... ;)

User avatar
Ceacy
Just popping in
Just popping in
Posts: 16
Joined: Sun May 22, 2005 20:28
Location: France, Paris.
Contact:

Re: UTF-8 Files and CEGUI::String

Postby Ceacy » Tue May 24, 2005 19:49

Nobody can help me ? :(

User avatar
lindquist
CEGUI Team (Retired)
Posts: 770
Joined: Mon Jan 24, 2005 21:20
Location: Copenhagen, Denmark

Re: UTF-8 Files and CEGUI::String

Postby lindquist » Tue May 24, 2005 20:31

In which manner do loose the accentuated characters ?

Are they not rendered?

Are you loading the appropriate glyphs when initialising your font ?

Does it work if you hardcode the strings and save your source in UTF8 format?

Some more information is needed to help you out of the blue!

User avatar
Ceacy
Just popping in
Just popping in
Posts: 16
Joined: Sun May 22, 2005 20:28
Location: France, Paris.
Contact:

Re: UTF-8 Files and CEGUI::String

Postby Ceacy » Wed May 25, 2005 12:07

They 're "just" not rendered. I've done some tests, and it seems that the text is correctly converted in CEGUI::String ; however, accentuated characters are not displayed :

Code: Select all

CEGUI::FontManager::getSingleton().createFont( "ForgottenUncial", "forgotten_uncial.ttf", 12, 0 );
// [...]
mGUISystem->setDefaultFont( (CEGUI::utf8*) "ForgottenUncial" ); // this font supports accentuated characters like "é", "è" ...
// [...]
std::ifstream fTextIntro( "intro_text.txt" );
   CEGUI::String strTextIntro;
   String strLine;
   if( fTextIntro )
   {
      while( std::getline( fTextIntro, strLine ) )
      {
         strTextIntro += (CEGUI::utf8*) strLine.c_str();
         strTextIntro += '\n';
      }
   }
   CEGUI::MultiLineEditbox* editbox = dynamic_cast<CEGUI::MultiLineEditbox*>( mSheet->getChild( (CEGUI::utf8*) "TextIntro" ) );
      editbox->setText( strTextIntro );
   
   std::cout << strTextIntro << std::endl;
   std::cout << editbox->getText() << std::endl;


Returns, in console :
Un monde, plat. Un monde où les Dieux sont comme tout le monde, mais en pire. Un monde où même une pluie de météorites violettes en forme de canards semblerait banale. Un monde où, par endroit, il est recommandé de vérifier au matin qu'on a bien la même forme que la veille.
Un monde où croire en un dieu, c'est le faire exister. Un monde de fous.

Un monde, plat. Un monde où les Dieux sont comme tout le monde, mais en pire. Un monde où même une pluie de météorites violettes en forme de canards semblerait banale. Un monde où, par endroit, il est recommandé de vérifier au matin qu'on a bien la même forme que la veille.
Un monde où croire en un dieu, c'est le faire exister. Un monde de fous.


But, in the editbox, i see :
Un monde, plat. Un monde o les Dieux sont comme tout le monde, mais en pire. Un monde o mme une pluie de mtorites violettes en forme de canards semblerait banale. Un monde o, par endroit, il est recommand de vrifier au matin qu'on a bien la mme forme que la veille.
Un monde o croire en un dieu, c'est le faire exister. Un monde de fous.


Any idea ?


---

EDIT : Oh. I've serached the forum with "glyphs" keyword, and I found.

Code: Select all

CEGUI::Font* font = CEGUI::System::getSingleton().getDefaultFont();
   CEGUI::String glyphSets( font->getAvailableGlyphs() );
      glyphSets += (CEGUI::utf8*) "éèêëàùûôöîï" ;
      font->defineFontGlyphs( glyphSets );

Sorry ...


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 3 guests