gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS Misc > How do you make a homebrew read in UTF8?

#160899 - whatevas - Thu Jul 24, 2008 4:44 am

I'm so sick and tired of DSOrganize not reading over half my files because their names have chinese characters in them. And since 3.2's source code was released, I want to know if I can make at least the Browser portion of it support unicode (UTF8).

I know it's possible, since Moonshell reads UTF8 just fine.

So how would I go about adding unicode support? Any classes I should be looking into?

#160912 - sgeos - Thu Jul 24, 2008 1:54 pm

Pick up the book "CJKV Information Processing" by Ken Lunde. 1100 pages of useful information (although the latter portion consists of glyph LUTs). You might also want to pick up another book on unicode, but I would do that after reading the section on Unicode in CJKV. That way, you should have lay knowledge to base your purchase on.

-Brendan

#160922 - whatevas - Thu Jul 24, 2008 3:53 pm

So there's no function that's usable for NDS coding in C/C++ that works like Java's InputStreamReader, or do you not understand my question?

#160925 - sgeos - Thu Jul 24, 2008 4:33 pm

whatevas wrote:
So there's no function that's usable for NDS coding in C/C++ that works like Java's InputStreamReader, or do you not understand my question?
Java natively uses unicode. C and C++ natively use ASCII, so dealing with Unicode is inherently non-trivial. As far as I know, there is nothing in the standard library that does the trick. I'm sure some, somewhere has unicode routines available. Google is probably a good place to start.

For what it is worth, I have not tried using the wide character routines to work with any of the unicode encoding formats. Even if the wide character routines can work with unicode, you still need fonts and there will probably be glyph mapping issues. None of this is trivial stuff. If you really want to work with character encoding formats, the book I mentioned is a highly recommended read/reference.

-Brendan

#160936 - whatevas - Thu Jul 24, 2008 6:37 pm

Interesting, I never knew C/C++ doesn't support it natively.

What if I want to use a 3rd party library such as this one which implements unicode file read/write, does NDS coding limit us to what libraries we can use?

#160938 - sgeos - Thu Jul 24, 2008 6:46 pm

whatevas wrote:
does NDS coding limit us to what libraries we can use?

The short answer is no, but in practice some libraries do not work out of the box or at all. You are free to give it a try.

Keep in mind that there are actually two issues when dealing with unicode- internal manipulation, and display. I suspect that the library you found handles internal manipulation. When working on the DS, you need to custom build a lot of things you can take for granted on the PC. In this case, appropriate fonts need to embedded in the application, and then you need to be able to map code points to font glyphs for the display.

k14.bdf is the font I used when I was doing this kind of thing on the GBA. There are probably other useful fonts bundled with k14.bdf.

-Brendan

#160946 - hacker013 - Thu Jul 24, 2008 8:01 pm

sgeos wrote:
whatevas wrote:
does NDS coding limit us to what libraries we can use?

The short answer is no, but in practice some libraries do not work out of the box or at all. You are free to give it a try.

Keep in mind that there are actually two issues when dealing with unicode- internal manipulation, and display. I suspect that the library you found handles internal manipulation. When working on the DS, you need to custom build a lot of things you can take for granted on the PC. In this case, appropriate fonts need to embedded in the application, and then you need to be able to map code points to font glyphs for the display.

k14.bdf is the font I used when I was doing this kind of thing on the GBA. There are probably other useful fonts bundled with k14.bdf.

-Brendan


maybe can someone make a port of libnds wich uses unicode instead of ancii
_________________
Website / Blog

Let the nds be with you.

#160956 - silent_code - Thu Jul 24, 2008 10:29 pm

I don't think it's needed to have a port of the whole libnds, but an extension library would sure come in handy for some developers.
_________________
July 5th 08: "Volumetric Shadow Demo" 1.6.0 (final) source released
June 5th 08: "Zombie NDS" WIP released!
It's all on my page, just click WWW below.

#160963 - sgeos - Fri Jul 25, 2008 3:39 am

No matter how I look at it, fonts are a big deal. I'm not aware of any complete unified unicode font. I'm sure one is out there, but I'd put my money on it being in vector format (not that you can't convert it). When it comes time to use bitmap fonts, things get even more dire.

Combining characters modify glyphs. Some code points are displayed as different glyphs depending on the text reading direction. I seem to recall other non-trivial things existing here and there in when it comes time to display text. Display is a big deal.

I do not see a full free unicode implementation happening of the DS any time soon, if ever. Supporting a few key languages with understood special features is doable.

-Brendan

#160974 - tepples - Fri Jul 25, 2008 12:59 pm

If you just want code for manipulating UTF-8 strings, you can borrow code from the Allegro library. But I wonder if Pango would compile on the DS.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#160981 - theli - Fri Jul 25, 2008 2:26 pm

i used those, not very nice and very simple functions for working with utf8 strings in JabberDS :)
http://rafb.net/p/TnaZHu73.html

#160987 - sgeos - Fri Jul 25, 2008 4:15 pm

tepples wrote:
If you just want code for manipulating UTF-8 strings, you can borrow code from the Allegro library. But I wonder if Pango would compile on the DS.

Is it easy to get fonts up and on the screen with Allegro?

-Brendan

#161044 - tepples - Sat Jul 26, 2008 10:54 pm

The Unicode routines in Allegro let a program iterate through a string a character at a time, even if the string is in the variable length encoding UTF-8 or UTF-16. Rendering these characters into glyphs is a separate matter. Allegro has font routines, but they need Allegro's blitter, and I haven't tried them on anything but European scripts.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.