Hi, I'm having some trouble reading and displaying file names that contain spanish chars like: México and Sueño.
All I wan't to know is how do I get the correct value for chars é and ñ.
When I run the program in Windows using DevC++ I can display those chars correctly but it doesn't work on psp.
I'm using the SDL SFont Suite library for displaying unicode strings.
Here is my code:
DIR *dhandle;
struct dirent *entry;
if((dhandle = opendir("ms0:/")) == NULL) {
pspDebugScreenPrintf("Error: couldn't open directory\n");
return 0;
}
int done = 0;
int y = 20;
while( !done ) {
entry = readdir(dhandle);
if( entry != 0 ) {
SFontSuiteText(screen,
10, 10, entry->d_name, 255);
}
else done = 1;
}
When I printf the hex value of the char é in DevC++ I obtain [e9] but in the psp i'm always getting [81 a1] for any char like á é í ó ú ñ, etc.
Well I hope anyone can help, Thanks
Using readdir and Spanish Dir Names
Re: Using readdir and Spanish Dir Names
because the filenam(dirname) saved in MS use Unicode,theHobbit wrote:Hi, I'm having some trouble reading and displaying file names that contain spanish chars like: México and Sueño.
All I wan't to know is how do I get the correct value for chars é and ñ.
When I run the program in Windows using DevC++ I can display those chars correctly but it doesn't work on psp.
I'm using the SDL SFont Suite library for displaying unicode strings.
Here is my code:
DIR *dhandle;
struct dirent *entry;
if((dhandle = opendir("ms0:/")) == NULL) {
pspDebugScreenPrintf("Error: couldn't open directory\n");
return 0;
}
int done = 0;
int y = 20;
while( !done ) {
entry = readdir(dhandle);
if( entry != 0 ) {
SFontSuiteText(screen,
10, 10, entry->d_name, 255);
}
else done = 1;
}
When I printf the hex value of the char é in DevC++ I obtain [e9] but in the psp i'm always getting [81 a1] for any char like á é í ó ú ñ, etc.
Well I hope anyone can help, Thanks
so when you create a dir or a new file, It will do a convert(spanish -> unicode) .
but when you use readdir to get the filename(dirname), it do a stupid thing, it use a convert ( unicode -> shift-jis).
so you get a wrong name string.
what you can do :
1. do a convert( shift-jis -> spanish), but it still have some wrong char.
2. read the MS's fat direct, get the unicode filename, and do a convert (unicode -> spanish), it is perfect.
Re: Using readdir and Spanish Dir Names
Thanks, searching the net I found this app eReader, it seems it uses the second option so i will give it a try!!"cooleyes
because the filenam(dirname) saved in MS use Unicode,
so when you create a dir or a new file, It will do a convert(spanish -> unicode) .
but when you use readdir to get the filename(dirname), it do a stupid thing, it use a convert ( unicode -> shift-jis).
so you get a wrong name string.
what you can do :
1. do a convert( shift-jis -> spanish), but it still have some wrong char.
2. read the MS's fat direct, get the unicode filename, and do a convert (unicode -> spanish), it is perfect.
Re: Using readdir and Spanish Dir Names
Yep, problem fixed. Well I used the fat code from the eReader source, and yes all I had to do was convert the unicode to spanish like cooleyes said. So thanks :)
Re: Using readdir and Spanish Dir Names
the "fat.c" in eReader have a bug, when it run at a 4G MS.theHobbit wrote:Yep, problem fixed. Well I used the fat code from the eReader source, and yes all I had to do was convert the unicode to spanish like cooleyes said. So thanks :)
you can get the fixed "fat.c" in my project PPA( pmplayer advance) , it fixed the bug when use a 4G MS
http://files.cngba.com/cooleyes/PPA/PPA ... 070331.rar
Re: Using readdir and Spanish Dir Names
Wow thanks again man, i will give it a try then.the "fat.c" in eReader have a bug, when it run at a 4G MS.
you can get the fixed "fat.c" in my project PPA( pmplayer advance) , it fixed the bug when use a 4G MS
http://files.cngba.com/cooleyes/PPA/PPA ... 070331.rar