Pablo César wrote:Thank you Mr. Yi for reporting your results and happy to know is satisfactory. The problem was not only for chinese characters, there are other languages with special characters that it could have been affected at time ago... now is solved, I guess.huiyi_ch wrote:After a preliminary test, the program(unicode and ANSI mode) for the INI file in Chinese characters, set and get all normal, the problem have been solved perfectly.
Now I am understanding what you was saying... You wrote chinese language mixed with codes and is very often to ignore other languages when we do not understanding... (sorry but it's the true, I often see this in Spanish section). Also your codes are not exemplified very well and you not so clear in your objective. Because we do not know what you presented it is your problem or if you are only presenting your opinion...huiyi_ch wrote:...question of the function getstatupfolder() viewtopic.php?f=43&t=4738&start=80, please pay attention a bit! If the next version the question will be solved , it would be great.
That is why when we do not master the English language, it is good to post in both languages (as you did in your last message posted).
Thus the user can translate himself from the native language at any other conciliating language (for example). Because sometimes google translator makes translation errors.
Regarding your suggestion (how to remove last unnecessary backslash), I do not seem to be the ideal solution. Since HMG works with UNICODE as default and these functions you have indicated are not for handling strings in UNICODE mode. And certainly folder names sometimes contain local language characters, so it should be handled in UNICODE mode not in ANSI.
My suggestion is to replace the GetStartUpFolder() function with the proper Harbour function use, like this:
Claudio, could this solution be adopted in HMG core ? Or replace GetStartUpFolder() function (eliminating at h_controlmisc.prg) with:Code: Select all
Function GetStartUpFolder() // by Pablo on November, 2016 - To remove last unnecessary backslash Return cFilePath(hb_ProgName())
#xtranslate GetStartUpFolder() =>cFilePath(hb_ProgName())
At ch file, as you prefer.
Remarks: Must be tested in ANSI mode to be sure all working properly for both modes. Please Mr. Yi: test it and revert to us.
Pablo César wrote:Hi Hui, Claudio and friends,
For UNICODE works perfectly, the question is for ANSI mode. Of course and rebuild HMG in ANSI and make tests.
I have tested with this code example and with this changing to see results:I have created a subfolder called "返回结果正确" and run it my demo and the bad result is this:Code: Select all
#include <hmg.ch> REQUEST HB_CODEPAGE_GBK Function Main hb_CdPSelect("GBK") MSGDEBUG(MyGetStartUpFolder()) Return Function MyGetStartUpFolder() // by Pablo on November, 2016 - To remove last unnecessary backslash LOCAL cStartUpFolder If HMG_IsCurrentCodePageUnicode() cStartUpFolder := cFilePath(hb_ProgName()) Else MsgInfo("In ANSI") cStartUpFolder := cFilePath(GetProgramFileName()) Endif If hb_ULeft(cStartUpFolder,1) = "\" cStartUpFolder := hb_ULeft( cStartUpFolder, HMG_Len( cStartUpFolder ) - 1 ) Endif Return cStartUpFolder
Screen17.png
I tried Claudio to modificate GETPROGRAMFILENAME and GETMODULEFILENAME replacing GetModuleFileName by GetModuleFileNameA in trying to pass working these C functions only for ANSI. But it didn't work.
Screen18.pngThis changing to GetModuleFileNameA, it doesn't compile in UNICODE.
How it could could for ANSI (which is the main problem) for get right folder name ?
Sorry Mr. Hui. My knowledge is very very limited (quite nothing) in C. So it's not more in my hands, I guess.
对于这些问题,我的解决办法是修改文件h_controlmisc.prg中的函数 GETSTARTUPFOLDER () 与cFilePath() ,修改后重新编译,经过测试(UNICODE和ANSI模式),函数GetStartUpFolder()和cFilePath() 返回结果正确。不知这样修改是否妥当?修改后的代码如下:
On these problems ,My solution is to modify the functions GETSTARTUPFOLDER () and cFilePath () in the file h_controlmisc.prg, modified and recompile, and test (UNICODE and ANSI mode). The functions GetStartUpFolder () and cFilePath () returns the results were correct. I wonder if this change is appropriate? The revised code is as follows:
Code: Select all
Function cFilePath( cFileMask )
Local cDir
// hb_FNameSplit( cFileMask, @cDir, @cName, @cExt, @cDrive )
hb_FNameSplit( cFileMask, @cDir, NIL, NIL, NIL )
// Return HB_ULEFT ( cDir, HMG_LEN( cDir ) - 1 )
Return LEFT ( cDir, LEN( cDir ) - 1 )
Function GetStartUpFolder()
Local StartUpFolder := GetProgramFileName()
// Return HB_ULEFT ( StartUpFolder , HB_UTF8RAT ( '\' , StartUpFolder ) - 1 )
Return LEFT ( StartUpFolder , RAT ( '\' , StartUpFolder ) - 1 )
Code: Select all
#include <hmg.ch>
request hb_codepage_gbk
Function Main
local path:=""
path:=cFilePath(hb_ProgName())
msginfo(path,"cFilePath()")
msginfo(getcurrentfolder(),"getcurrentfolder()")
msginfo(getStartupfolder(),"getStartupfolder()")
hb_CdPSelect("GBK") //with chinese os, on ANSI mode must use hb_CdPSelect("GBK") ,else display "?????"
path:=cFilePath(hb_ProgName())
msginfo(path,"cFilePath()")
msginfo(getcurrentfolder(),"getcurrentfolder()")
msginfo(getStartupfolder(),"getStartupfolder()")
Return