HMG 3.4.3

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: HMG 3.4.3

Post by KDJ »

Pablo, so we invite you on vacation to Poland.
Polish language you almost mastered, therefore there will be no communication problems.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

HMG 3.4.3

Post by Pablo César »

Thanks a lot. The same I can tell you when you would like to come to south of Brasil.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

HMG 3.4.3

Post by Pablo César »

Hi Mr. Hui,

Regarding GetStartUpFolder in ANSI

Any news ? Have you solved ? Have you tested my pre-solution ?

Please give us return...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: HMG 3.4.3

Post by huiyi_ch »

Pablo César 您好,

我这几天由于休假,没有及时将测试结果回复,请谅解.
我下载了您的程序并进行了测试(在UNICODE和ANSI模式下),结果一切正常.我觉得您的解决方案更稳妥,兼容性更好.非常感谢您的付出.

Hello Pablo César,

I am a few days due to leave, not in time to test results back, please understand.
I downloaded your program and tested it (in UNICODE and ANSI mode) and everything worked fine. I found your solution to be more secure and more compatible. Thank you very much.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

HMG 3.4.3

Post by Pablo César »

Hi Mr. Hui,

Thank you for reporting.
huiyi_ch wrote:tested it (in UNICODE and ANSI mode) and everything worked fine
That's good ! Is that what I wanted to know. If in ANSI is working good. Because for me it was working a little bit strange in ANSI by my last tests.

Have the ANSI strings been treated or are you using directly without any problem?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: HMG 3.4.3

Post by huiyi_ch »

Once again, I tested the function MyGetStartUpFolder (), In ANSI mode, the function returns the correct result.

Code: Select all


#include <hmg.ch>

REQUEST HB_CODEPAGE_GBK

Function Main
local cpath,i
MyGetStartUpFolder()
hb_CdPSelect("GBK") // "CP936" // GB2312
cpath:=MyGetStartUpFolder()
for i:=1 to ostring:len(cpath) 
msginfo(ostring:substr(cpath,i,1))
next 
Return

Function MyGetStartUpFolder()    // by Pablo on November, 2016 - To remove last unnecessary backslash
LOCAL cStartUpFolder := cFilePath(hb_ProgName())

If HMG_IsCurrentCodePageUnicode()
   If hb_URight(cStartUpFolder,1) = "\"
      cStartUpFolder := hb_URight( cStartUpFolder, HMG_Len( cStartUpFolder ) - 1 )
   Endif
   MSGDEBUG("UNICODE",cStartUpFolder)
Else
   If Right(cStartUpFolder,1) = "\"
      cStartUpFolder := SubStr( cStartUpFolder, 1, Len( cStartUpFolder ) - 1 )
   Endif
   MSGDEBUG("ANSI",cStartUpFolder)
Endif
Return cStartUpFolder
ansi_mode.jpg
ansi_mode.jpg (81.2 KiB) Viewed 5826 times
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

HMG 3.4.3

Post by Pablo César »

Thank you Mr. Hui.

My system is not in Chinese and I could not test in ANSI.

Dr. Claudio, do you think that is posible to officially replace actual GetStartUpFolder() by this MyGetStartUpFolder() for us ? (not with the same name, of course).

Code: Select all

Function MyGetStartUpFolder()    // by Pablo on November, 2016 - To remove last unnecessary backslash
LOCAL cStartUpFolder := cFilePath(hb_ProgName())

If HMG_SupportUnicode()
   If hb_URight(cStartUpFolder,1) = "\"
      cStartUpFolder := hb_URight( cStartUpFolder, HMG_Len( cStartUpFolder ) - 1 )
   Endif
   MSGDEBUG("UNICODE",cStartUpFolder)
Else
   If Right(cStartUpFolder,1) = "\"
      cStartUpFolder := SubStr( cStartUpFolder, 1, Len( cStartUpFolder ) - 1 )
   Endif
   MSGDEBUG("ANSI",cStartUpFolder)
Endif
Return cStartUpFolder
Last edited by Pablo César on Tue Nov 29, 2016 5:12 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HMG 3.4.3

Post by srvet_claudio »

Pablo César wrote:Thank you Mr. Hui.

My system is not in Chinese and I could not test in ANSI.

Dr. Claudio, do you think that is posible to officially replace actual GetStartUpFolder() by this MyGetStartUpFolder() for us ? (not with the same name, of course).

Code: Select all

Function MyGetStartUpFolder()    // by Pablo on November, 2016 - To remove last unnecessary backslash
LOCAL cStartUpFolder := cFilePath(hb_ProgName())

If HMG_IsCurrentCodePageUnicode()
   If hb_URight(cStartUpFolder,1) = "\"
      cStartUpFolder := hb_URight( cStartUpFolder, HMG_Len( cStartUpFolder ) - 1 )
   Endif
   MSGDEBUG("UNICODE",cStartUpFolder)
Else
   If Right(cStartUpFolder,1) = "\"
      cStartUpFolder := SubStr( cStartUpFolder, 1, Len( cStartUpFolder ) - 1 )
   Endif
   MSGDEBUG("ANSI",cStartUpFolder)
Endif
Return cStartUpFolder
The code duplication is unnecessary, all HB_Uxxx functions work with ANSI and Unicode.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

GetStartUpFolder()

Post by Pablo César »

Hi Claudio,

I also would agree with you about hb_U... functions are compactibles for UNICODE and ANSI modes. But... :?

I have tested my friend. Tested with this chinese characters (not our language) I and can confirm to you there is something wrong with hb_USubStr when is chinese characters in ANSI mode.

You can do by yourself this test of demo:
test.rar
Sources, Executable and chinese subfolder name
(2.57 MiB) Downloaded 219 times
But please download this, unpack and run in the chinese subfolder with name "返回结果正确" (but HMG must be rebuilded in ANSI mode). Then you will see it's working removing last backslash. Because is using SubStr intead of hb_USubStr. You can change in the code and compile (the sub-folder will be also updated too automactically). Please Claudio, test it and prove it.

But the right code to replaces GetStartUpFolder by this MyGetStartUpFolder:

Code: Select all

Function MyGetStartUpFolder()    // by Pablo on November, 2016 - To remove last unnecessary backslash
LOCAL cStartUpFolder := cFilePath(hb_ProgName())

If HMG_SupportUnicode()
   If hb_URight(cStartUpFolder,1) = "\"
      cStartUpFolder := hb_USubStr( cStartUpFolder, 1, HMG_Len( cStartUpFolder ) - 1 )
   Endif
Else
   If Right(cStartUpFolder,1) = "\"
      cStartUpFolder := SubStr( cStartUpFolder, 1, Len( cStartUpFolder ) - 1 )
   Endif
Endif
Return cStartUpFolder
Please understand replacement but with the same name of function: GetStartUpFolder() with the contain above code listed.

Please also note, was wrongly using HMG_IsCurrentCodePageUnicode() instead of HMG_SupportUnicode(). I have replaced and this is the right one, same that Mr. Hui tested and corrected in my previous messages too.

Please confirm.
Last edited by Pablo César on Wed Nov 30, 2016 9:03 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HMG 3.4.3

Post by srvet_claudio »

I will check
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Post Reply