forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using readdir and Spanish Dir Names

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Fri Apr 06, 2007 9:09 am    Post subject: Using readdir and Spanish Dir Names Reply with quote

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
Back to top
View user's profile Send private message
cooleyes



Joined: 18 May 2006
Posts: 125

PostPosted: Fri Apr 06, 2007 11:29 am    Post subject: Re: Using readdir and Spanish Dir Names Reply with quote

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


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.
Back to top
View user's profile Send private message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Fri Apr 06, 2007 1:03 pm    Post subject: Re: Using readdir and Spanish Dir Names Reply with quote

Quote:
"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.


Thanks, searching the net I found this app eReader, it seems it uses the second option so i will give it a try!!
Back to top
View user's profile Send private message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Fri Apr 06, 2007 1:44 pm    Post subject: Re: Using readdir and Spanish Dir Names Reply with quote

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 :)
Back to top
View user's profile Send private message
cooleyes



Joined: 18 May 2006
Posts: 125

PostPosted: Fri Apr 06, 2007 2:38 pm    Post subject: Re: Using readdir and Spanish Dir Names Reply with quote

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 :)


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.source.20070331.rar
Back to top
View user's profile Send private message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Sat Apr 07, 2007 2:57 am    Post subject: Re: Using readdir and Spanish Dir Names Reply with quote

Quote:

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.source.20070331.rar


Wow thanks again man, i will give it a try then.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group