Changes

Jump to navigation Jump to search
1,046 bytes added ,  08:31, 23 March 2009
Line 49: Line 49:  
</source>
 
</source>
 
--[[User:Crayon|Crayon]] 03:52, 23 March 2009 (UTC)
 
--[[User:Crayon|Crayon]] 03:52, 23 March 2009 (UTC)
 +
 +
== Problem with Mii's name ==
 +
 +
First of all, you declare it like that:<BR>
 +
char name[MII_NAME_LENGTH];<BR>
 +
There is two mistake here, the first one is that characters are two bytes (addr: 0x02 through 0x15) so it should be:<BR>
 +
char name[MII_NAME_LENGTH * 2];<BR>
 +
The second one is there should always a place for the NULL character at the end, so it should be like this:<BR>
 +
char name[MII_NAME_LENGTH * 2 + 1];<BR>
 +
Now to accept UTF8 chars:
 +
<source lang="c">
 +
int c, d;
 +
char tempChar;
 +
for (c=0, d=0;d<MII_NAME_LENGTH;c++, d++){
 +
        tempChar = data[start + 0x02 + d * 2 + 1];
 +
        if(tempChar < 0x80)
 +
            mii.name[c] = tempChar;
 +
        else{
 +
            mii.name[c] = (((tempChar) >>  6) & 0x1F) | 0xC0;
 +
            c++;
 +
            mii.name[c] = ((tempChar) & 0x3F) | 0x80;
 +
        }
 +
}
 +
mii.name[MII_NAME_LENGTH*2] = '\0';
 +
</source>
 +
The code has been tested just a bit with freetype in C++ with some Latin chars. So it needs more test, right now I'm too tired to continue ;)<BR>
 +
The same problem applies to the creator name.
3,027

edits

Navigation menu