Page 1 of 2
How to create Chinese named online folder and file
Posted: Sat Sep 24, 2016 11:29 am
by AlanFoo
Hi experts,
I need some help .
I tried to create a chinese named folder at my server with the following command ..
CreateFTPDirectory(6, "direct/"+keywordname$) where keywordname$ is a string having Chinese charaters e.g. test 报 报 报
However the folder created online at my server came up with '???' where ? replaces each Chinese character.
and when I ftp
If SendFTPFile(6,recdirect$,"direct/"+keywordname$+"/"+keywordname$+"index.php") the file is also having ??? replacing each Chinese character.
Is there any way to create folders and file using Chinese ? Using PHP online is okay no problem but directly from Purebasic I have this problem.
Can anyone kind expert here help me on this.
Thanks in advance for your help
Warmest regards
Alan
Re: How to create Chinese named online folder and file
Posted: Sat Sep 24, 2016 11:33 am
by Keya
you didnt mention unicode/ascii, so first is to check that you're compiling in unicode mode in PB
Re: How to create Chinese named online folder and file
Posted: Sat Sep 24, 2016 2:00 pm
by IdeasVacuum
the folder created online at my server came up with '???' where ? replaces each Chinese character.
How did you see that? If via another desktop app, then that needs to support Unicode - and Unicode font. Or using an online 'Control Panel' provided by your Web Host? Check that they support Unicode (they absolutely should).
Re: How to create Chinese named online folder and file
Posted: Sun Sep 25, 2016 1:15 am
by AlanFoo
IdeasVacuum wrote:the folder created online at my server came up with '???' where ? replaces each Chinese character.
How did you see that? If via another desktop app, then that needs to support Unicode - and Unicode font. Or using an online 'Control Panel' provided by your Web Host? Check that they support Unicode (they absolutely should).
I view the files through filezilla FTP . I have other files/folders in Chinese saved through PHP not Purebasic.
My compiler is run under unicode and all the messages viewed before sending to server can be seen as Chinese so the compiler is compiling under Chinese(utf8)
But the end result of the folder and file saved created '?' for each Chinese Character. This goes to any language.
So I wonder how others are saving and sending files to the server and the names can be in utf8 ?
Thanks for your answers Keya and IdeasVacuum
Alan
Re: How to create Chinese named online folder and file
Posted: Sun Sep 25, 2016 4:07 am
by Keya
you could also use a packet sniffer like Wireshark to ensure they're being sent ok
Re: How to create Chinese named online folder and file
Posted: Sun Sep 25, 2016 5:26 am
by AlanFoo
Keya wrote:you could also use a packet sniffer like Wireshark to ensure they're being sent ok
Actually I am sure it is not sent okay as it is intended to be.. to be Chinese/English/Arabic names as the original file from our computer.
it actually is unable to send the utf8 characters over to the server . It sends only normal ascii characters.
Just wonder how others configure it to be able to upload and create folders with names in their mother tongue instead of romanised English characters.
Alan
Re: How to create Chinese named online folder and file
Posted: Sun Sep 25, 2016 11:26 am
by IdeasVacuum
Just wonder how others configure it to be able to upload and create folders with names in their mother tongue instead of romanised English characters.
Well in fact, in most cases they actually do use English. It's the same with email addresses - the standards and protocols support Unicode solutions (RFC 6530, RFC 6531, RFC 6532, RFC 6533) but most mail servers simply do not.
However, if connected to the server via FileZilla, you can rmc create a new directory. The window that pops-up does accept UTF8 and so you can have your Chinese folder titles. It might mean that uploads to the folder get tricky, that will need to be tested.
Re: How to create Chinese named online folder and file
Posted: Tue Sep 27, 2016 2:33 am
by AlanFoo
IdeasVacuum wrote:Just wonder how others configure it to be able to upload and create folders with names in their mother tongue instead of romanised English characters.
Well in fact, in most cases they actually do use English. It's the same with email addresses - the standards and protocols support Unicode solutions (RFC 6530, RFC 6531, RFC 6532, RFC 6533) but most mail servers simply do not.
However, if connected to the server via FileZilla, you can rmc create a new directory. The window that pops-up does accept UTF8 and so you can have your Chinese folder titles. It might mean that uploads to the folder get tricky, that will need to be tested.
Yes , i can already do that with filezilla ftp program. Can create rename it etc.
But when I used
CreateFTPDirectory(6, "direct/"+keywordname$) where keywordname$ is a string having Chinese charaters e.g. test 报 报 报
the folder created was test ???
This has to do with utf8 setting somewhere at the purebasic program level..
I use the Purebasic compiler and checked the box 'Create unicode executable"
I does show the utf8 characters in the program...only the online create does not work.
Surely some foreign non English countries users must have encountered this issue when using ftp programs.
Regards
Alan
Re: How to create Chinese named online folder and file
Posted: Tue Sep 27, 2016 10:55 am
by IdeasVacuum
Surely some foreign non English countries users must have encountered this issue when using ftp programs.
I'd say until now, no they haven't because they had to use English. No doubt English will continue to be necessary in the short term but change will come. That change though will not be ubiquitous, multi-national companies for example see English as the neutral language anyway.
Re: How to create Chinese named online folder and file
Posted: Tue Sep 27, 2016 11:28 am
by IdeasVacuum
Code: Select all
InitNetwork()
If OpenFTP(0, url, user, pass, 21)
CreateFTPDirectory(0, "报 报 报")
CloseFTP(0)
Else
MessageRequester("Owch", "FTP connection failed")
EndIf
Tried the above snippet and got the same result as you on my server. Unless FileZilla does something clever, such as introducing it's own unicode font, it would seem that PB's CreateFTPDirectory() is ASCII only.
Re: How to create Chinese named online folder and file
Posted: Tue Sep 27, 2016 11:33 am
by AlanFoo
IdeasVacuum wrote:Code: Select all
InitNetwork()
If OpenFTP(0, url, user, pass, 21)
CreateFTPDirectory(0, "报 报 报")
CloseFTP(0)
Else
MessageRequester("Owch", "FTP connection failed")
EndIf
Tried the above snippet and got the same result as you on my server. Unless FileZilla does something clever, such as introducing it's own unicode font, it would seem that PB's CreateFTPDirectory() is ASCII only.
Yes I think so... they forgot about the rest of the world's languages :>)
What I can do is to send up a file to my server and then use php to create the folder...
Trying it now.
For this to runprogram the php module on my server to get the file , read the chinese content and save it as a folder with Chinese.
Thanks for your time and effort.
Alan
Re: How to create Chinese named online folder and file
Posted: Tue Sep 27, 2016 1:11 pm
by IdeasVacuum
So, I'm thinking PB is using API FtpCreateDirectoryA(), so we could try FtpCreateDirectoryW()
Code: Select all
#INTERNET_OPEN_TYPE_DIRECT = 1
#INTERNET_SERVICE_FTP = 1
Global.i hOpen, hConn, iPort = 21
Global.s sUrl = "myUrl" ;exclude prefix http:// or ftp://
Global.s sUser = "myUser"
Global.s sPass = "myPass"
Global.s sDir = "可以给"
Prototype.i FtpCreateDirectoryW(hConnect.i, sDir.s)
hOpen = InternetOpen_("FTP", #INTERNET_OPEN_TYPE_DIRECT, #Null$, #Null$, iPort)
If hOpen
hConn = InternetConnect_(hOpen, sUrl, iPort, sUser, sPass, 1, #INTERNET_SERVICE_FTP, 0)
If hConn
If OpenLibrary(0, "wininet.dll")
FtpCreateDir.FtpCreateDirectoryW = GetFunction(0, "FtpCreateDirectoryW")
FtpCreateDir(hConn, sDir)
CloseLibrary(0)
EndIf
InternetCloseHandle_(hConn)
Else
Debug "Connection Failed"
EndIf
InternetCloseHandle_(hOpen)
Else
Debug "Init failed"
EndIf
....fails the same, folder is named "???"

However, it could be that the string has to be 'massaged' before use.
Re: How to create Chinese named online folder and file
Posted: Tue Sep 27, 2016 1:52 pm
by Keya
CreateFTPDirectory() doesn't use FtpCreateDirectoryA/W at all, just winsock commands send/recv
Re: How to create Chinese named online folder and file
Posted: Tue Sep 27, 2016 4:07 pm
by IdeasVacuum
Possibly the method to get FtpCreateDirectoryW to work is to convert the folder name with MultiByteToWideChar_
Edit: No, that doesn't sound right. As I understand it, WideChar is unicode (UTF16).
Tried changing the prototype thus:
Code: Select all
Prototype.i FtpCreateDirectoryW(hConnect.i, sDirName.p-unicode)
Also tried 'building' the folder name with chars:
Code: Select all
Global.s sDir = Chr(21487) + Chr(20197) + Chr(32473) ;"可以给"
.... made no difference.
Re: How to create Chinese named online folder and file
Posted: Wed Sep 28, 2016 1:16 am
by AlanFoo
IdeasVacuum wrote:Possibly the method to get FtpCreateDirectoryW to work is to convert the folder name with MultiByteToWideChar_
Edit: No, that doesn't sound right. As I understand it, WideChar is unicode (UTF16).
Tried changing the prototype thus:
Code: Select all
Prototype.i FtpCreateDirectoryW(hConnect.i, sDirName.p-unicode)
Also tried 'building' the folder name with chars:
Code: Select all
Global.s sDir = Chr(21487) + Chr(20197) + Chr(32473) ;"可以给"
.... made no difference.
Maybe the Purebasic development team can help out? It seems that so far it cannot do that.
Meanwhile I used php to do it. ftp a file over with chinese contents , use php to read that and saved the file name in Chinese . it works this way . But then the curiosity is why PB does not allow this.
Alan