Advertising (This ad goes away for registered users. You can Login or Register)

umlauts like ü, ö, ä with oslib

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Locked
failbit
Posts: 48
Joined: Fri Apr 08, 2011 1:43 pm

umlauts like ü, ö, ä with oslib

Post by failbit »

Hello I have a little problem with the oslib. I added a multi-language support to my game Mobile Skat. The languages are read out from a file. All works good except the german translation.
When I use a ü or ö in the file it will not be displayed on my psp. I use Intrafont with the oslib and UTF-8 encoding. Do you have an idea how to fix this ?
Advertising
MIPS: Misleading Information to Promote Sales
Play Skat on your PSP:
viewtopic.php?f=26&t=5085
Strangelove
Posts: 286
Joined: Thu Nov 25, 2010 6:32 pm

Re: umlauts like ü, ö, ä with oslib

Post by Strangelove »

failbit wrote:Hello I have a little problem with the oslib. I added a multi-language support to my game Mobile Skat. The languages are read out from a file. All works good except the german translation.
When I use a ü or ö in the file it will not be displayed on my psp. I use Intrafont with the oslib and UTF-8 encoding. Do you have an idea how to fix this ?
we don't read minds. more clues are needed.

1. all the lines you use to initialize font rendering.
2. you say you use utf8. do you store the text in .c files. or in external files.
3. in which variable type or class do you store text?
4. at any point do you perform ANY kind of text conversion or alteration? which.
Advertising
"If you have specific questions ... don't hesitate to ask as the more generic the question is the more philosophic the answer will be" - PSPWizard
failbit
Posts: 48
Joined: Fri Apr 08, 2011 1:43 pm

Re: umlauts like ü, ö, ä with oslib

Post by failbit »

1. the lines to init the font rendering:

Code: Select all

oslInit(OSL_IF_USEOWNCALLBACKS);
oslInitGfx(OSL_PF_8888, 1);
oslInitAudio();

oslIntraFontInit(INTRAFONT_CACHE_ALL | INTRAFONT_STRING_UTF8); 
ltn0 = oslLoadFontFile("flash0:/font/ltn0.pgf");
oslIntraFontSetStyle(ltn0, 1.0f,WHITE,BLACK,INTRAFONT_ALIGN_CENTER);
oslSetFont(ltn0);
2. the text is stored in a simple .txt file

3. the file is loaded into a char array with this function:

Code: Select all

int open_lang_file(char path[])
{
	int v       = 0;

    FILE* f = fopen(path, "r");

	if(f == 0)
	{
		show_message_dialog("Can't open language-file!",0);
		return 0;
	}

    char line[50];
    
    while(fgets(line, 50, f))
    {
        if(line[0] != 0)
		{
			sprintf(languagestr[v], "%s",line);
		}
		else
		{
			char message[50];
			sprintf(message, "Error while reading language packages at %d!",v);
			show_message_dialog(message, 0);
			return 0;
		}
		v++;
    } 

	fclose(f);
	return 1;
}
later the text stored in the array is printed to screen like this:

Code: Select all

oslStartDrawing();
oslIntraFontSetStyle(ltn0, 1.2f,WHITE,BLACK,INTRAFONT_ALIGN_CENTER);
oslDrawStringf(240, 20, languagestr[1]);
oslEndDrawing();
oslEndFrame();
oslSyncFrame();
4. no, not knowingly

Thanks for the fast reply.
MIPS: Misleading Information to Promote Sales
Play Skat on your PSP:
viewtopic.php?f=26&t=5085
Strangelove
Posts: 286
Joined: Thu Nov 25, 2010 6:32 pm

Re: umlauts like ü, ö, ä with oslib

Post by Strangelove »

Ok. I'm guessing the problem lies here:

Code: Select all

oslLoadFontFile("flash0:/font/ltn0.pgf");
There's no such thing as latin-0 so why Sony names it as such is beyond me. i'm also not sure what letters it covers.
Also both latin-1 and latin-15 covers the letters you want, so try using ltn1.pgf and ltn15.pgf and see if that does the trick.
"If you have specific questions ... don't hesitate to ask as the more generic the question is the more philosophic the answer will be" - PSPWizard
The Z
VIP
Posts: 5505
Joined: Thu Jan 27, 2011 4:26 pm
Location: Deutschland
Contact:

Re: umlauts like ü, ö, ä with oslib

Post by The Z »

failbit wrote:Hello I have a little problem with the oslib. I added a multi-language support to my game Mobile Skat. The languages are read out from a file. All works good except the german translation.
When I use a ü or ö in the file it will not be displayed on my psp. I use Intrafont with the oslib and UTF-8 encoding. Do you have an idea how to fix this ?
Dont forget the ß umlaut ;)
White PSV TV - 32GB - 3.65 CFW
White PSV 1000 - 32GB - 3.65 CFW
2x PSV 2000 - 32/64GB - 3.65 CFW
PSP Fat 1000 - TA-081 - 6.61 ME-2.3
PSP Slim 2000 - TA-085¹ - 6.61 ME-2.3
4x PSPgo & 1x PSP 3kº⁴ᶢ - 6.61 LME-2.3∞
failbit
Posts: 48
Joined: Fri Apr 08, 2011 1:43 pm

Re: umlauts like ü, ö, ä with oslib

Post by failbit »

I changed the font to ltn1 and then to ltn15 but the word "Menü" is still "Men" in the game.
EDIT:
I use now ltn8.pgf like in the intrafontsample in psp-sdk. When i write it as hexadezimal(e.g \xC3\xA5) and pass it directly to oslDrawString then an ""a" with a circle on top" is printed on screen. But when I try the same by loading \xC3\xA5 from a file it gives me \xC3\xA5 and not ""a" with a circle on top".

EDIT:
So now I finally got it! I have to replace the ü with the hexadezimal number in a hex editor so I have to write C3BC for it.

Thanks for your help!
MIPS: Misleading Information to Promote Sales
Play Skat on your PSP:
viewtopic.php?f=26&t=5085
Strangelove
Posts: 286
Joined: Thu Nov 25, 2010 6:32 pm

Re: umlauts like ü, ö, ä with oslib

Post by Strangelove »

failbit wrote:I changed the font to ltn1 and then to ltn15 but the word "Menü" is still "Men" in the game.
Then perhaps your text file isn't really UTF-8? Try loading it with firefox and set character encoding to UTF-8 to verify. Does all characters show up correctly?

To find out which encoding and character-set it uses change the settings until it displays correctly.
I use now ltn8.pgf like in the intrafontsample in psp-sdk. When i write it as hexadezimal(e.g \xC3\xA5) and pass it directly to oslDrawString then an ""a" with a circle on top" is printed on screen. But when I try the same by loading \xC3\xA5 from a file it gives me \xC3\xA5 and not ""a" with a circle on top".
the compiler translate string literals before saving them, so this happens compile-time and not run-time.
only printf format specifiers (%c %x etc.) work run-time.
"If you have specific questions ... don't hesitate to ask as the more generic the question is the more philosophic the answer will be" - PSPWizard
Locked

Return to “Programming and Security”