HMG 3.4.3

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

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 i will check.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
kcarmody
Posts: 152
Joined: Tue Oct 07, 2014 11:13 am
Contact:

Re: HMG 3.4.3

Post by kcarmody »

Pablo César wrote:
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.
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.
Great work, Pablo!
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 Kevin :)
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 »

Claudio Soto博士您好:
我想向您提一点建议,请在HMG_TString类中,增加按字节提取字符串的一些方法,尤其在ANSI模式下,我认为很有必要!这样在使用HMG_TString类对字符串进行处理时,将变的更加统一、规范、方便。


Hello Dr. Claudio Soto
I want to make a suggestion to you, please in the HMG_TString class, increase some methods for extracting parts of a character string by byte, especially in the ANSI mode, I think it is necessary! So,when using HMG_TString class to operate the string, will become more unified, standardized, convenient.

METHOD BLeft (cString, nCount) INLINE HB_BLEFT (cString, nCount)
METHOD BRight(cString, nCount) INLINE HB_BRIGHT (cString, nCount)
METHOD BSubStr(cString, nStart, nCount) INLINE HB_BSUBSTR (cString, nStart, nCount)
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 »

huiyi_ch wrote:Claudio Soto博士您好:
我想向您提一点建议,请在HMG_TString类中,增加按字节提取字符串的一些方法,尤其在ANSI模式下,我认为很有必要!这样在使用HMG_TString类对字符串进行处理时,将变的更加统一、规范、方便。


Hello Dr. Claudio Soto
I want to make a suggestion to you, please in the HMG_TString class, increase some methods for extracting parts of a character string by byte, especially in the ANSI mode, I think it is necessary! So,when using HMG_TString class to operate the string, will become more unified, standardized, convenient.

METHOD BLeft (cString, nCount) INLINE HB_BLEFT (cString, nCount)
METHOD BRight(cString, nCount) INLINE HB_BRIGHT (cString, nCount)
METHOD BSubStr(cString, nStart, nCount) INLINE HB_BSUBSTR (cString, nStart, nCount)
HB_Uxxx string functions work with any CP ( ANSI and Unicode ).
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: HMG 3.4.3

Post by huiyi_ch »

Hello Pablo César
经过测试,嵌套函数cFilePath(hb_ProgName())
在UNICODE模式,不论文件路径中有无中文字符,返回结果都正常!
在ANSI模式下,如果文件路径中存在中文字符,嵌套函数cFilePath(hb_ProgName())返回结果会多一个"\"字符,但getcurrentfolder()返回结果正确!

After testing, nested function cFilePath (hb_ProgName ())
In UNICODE, whether file path contain or not Chinese characters, return the results are normal!
In ANSI mode, if the file path contain Chinese characters, the nested function cFilePath (hb_ProgName()) returns the result incorrect , But getcurrentfolder () returns the result is normal.
path contain  Chinese characters
path contain Chinese characters
IMG.jpg (20.16 KiB) Viewed 7231 times
getcurrentfolder() return result
getcurrentfolder() return result
jpeg2.jpg (25.06 KiB) Viewed 7229 times

Code: Select all

#include <hmg.ch>
request hb_codepage_gbk  
Function Main()
    local path:=""
    hb_CdPSelect("GBK")  //with chinese os, in ANSI moden  must used hb_CdPSelect("GBK") ,else display "?????"
    path:=cFilePath(hb_ProgName())
    msginfo(path)
    msginfo(getcurrentfolder())
Return nil
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: HMG 3.4.3

Post by huiyi_ch »

srvet_claudio wrote:
huiyi_ch wrote:Claudio Soto博士您好:
我想向您提一点建议,请在HMG_TString类中,增加按字节提取字符串的一些方法,尤其在ANSI模式下,我认为很有必要!这样在使用HMG_TString类对字符串进行处理时,将变的更加统一、规范、方便。


Hello Dr. Claudio Soto
I want to make a suggestion to you, please in the HMG_TString class, increase some methods for extracting parts of a character string by byte, especially in the ANSI mode, I think it is necessary! So,when using HMG_TString class to operate the string, will become more unified, standardized, convenient.

METHOD BLeft (cString, nCount) INLINE HB_BLEFT (cString, nCount)
METHOD BRight(cString, nCount) INLINE HB_BRIGHT (cString, nCount)
METHOD BSubStr(cString, nStart, nCount) INLINE HB_BSUBSTR (cString, nStart, nCount)
HB_Uxxx string functions work with any CP ( ANSI and Unicode ).
Hello Dr. Claudio Soto
It is very possible that you do not understand what I mean! In HMG, I will use the method of the hmg_string class in a unified way, without going to use the function!
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 »

huiyi_ch wrote:
srvet_claudio wrote:
huiyi_ch wrote:Claudio Soto博士您好:
我想向您提一点建议,请在HMG_TString类中,增加按字节提取字符串的一些方法,尤其在ANSI模式下,我认为很有必要!这样在使用HMG_TString类对字符串进行处理时,将变的更加统一、规范、方便。


Hello Dr. Claudio Soto
I want to make a suggestion to you, please in the HMG_TString class, increase some methods for extracting parts of a character string by byte, especially in the ANSI mode, I think it is necessary! So,when using HMG_TString class to operate the string, will become more unified, standardized, convenient.

METHOD BLeft (cString, nCount) INLINE HB_BLEFT (cString, nCount)
METHOD BRight(cString, nCount) INLINE HB_BRIGHT (cString, nCount)
METHOD BSubStr(cString, nStart, nCount) INLINE HB_BSUBSTR (cString, nStart, nCount)
HB_Uxxx string functions work with any CP ( ANSI and Unicode ).
Hello Dr. Claudio Soto
It is very possible that you do not understand what I mean! In HMG, I will use the method of the hmg_string class in a unified way, without going to use the function!
It's making sense, his request Claudio.

These ones are missing at HMG_TString class:

Code: Select all

      METHOD BLeft (cString, nCount)            INLINE   HB_BLEFT (cString, nCount)
      METHOD BRight(cString, nCount)            INLINE   HB_BRIGHT (cString, nCount)
      METHOD BSubStr(cString, nStart, nCount)   INLINE   HB_BSUBSTR (cString, nStart, nCount)
Having these, can also be dual interpreted in ANSI and UNICODE.
You have mentioned these Harbour function here but not included... :|

So I have not used before HB_B family... but nevertheless it would be good to have it in HMG. And can be added others like: HB_BAT, HB_BLEN, HB_BCODE, HB_BPEEK, HB_BPOKE and HB_BCHAR ?

Someone could tell me for what is it used for ? ( something about binary/byte ? :? )

I found this from Viktor Szakats for NTP functions:

Code: Select all

STATIC FUNCTION ntohl( c )

   IF hb_Version( HB_VERSION_ENDIANNESS ) == HB_VERSION_ENDIAN_LITTLE
      RETURN ;
         hb_BSubStr( c, 4, 1 ) + ;
         hb_BSubStr( c, 3, 1 ) + ;
         hb_BSubStr( c, 2, 1 ) + ;
         hb_BSubStr( c, 1, 1 )
   ENDIF

   RETURN c
Claudio, please note constants HB_VERSION_ENDIANNESS and HB_VERSION_ENDIAN_LITTLE.
Could it be useful (this checking) for something to us ?
Or just for as reference ?
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 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:

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
I have created a subfolder called "返回结果正确" and run it my demo and the bad result is this:
Screen17.png
Screen17.png (13.02 KiB) Viewed 7188 times
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. :cry:
Screen18.png
Screen18.png (44.02 KiB) Viewed 7186 times
This 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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: HMG 3.4.3

Post by KDJ »

Hi Pablo

ANSI versions of these functions:

Code: Select all

HB_FUNC( GETPROGRAMFILENAMEA )
{
   CHAR Buffer [MAX_PATH + 1];
   GetModuleFileNameA(GetModuleHandle(NULL), Buffer, MAX_PATH);
   hb_retc(Buffer);
}

HB_FUNC( GETMODULEFILENAMEA )
{
   CHAR Buffer [MAX_PATH + 1];
   HMODULE hModule = HB_ISNIL(1) ? GetModuleHandle(NULL) : (HMODULE) HMG_parnl(1);
   GetModuleFileNameA(hModule, Buffer, MAX_PATH);
   hb_retc(Buffer);
}
Post Reply