HMG_TString Class

 

 

 

This class selects automatically the correct ANSI or Unicode string function depending of current code page, the use of this class create a more portable your code, and is useful for a defensive programming (minimization of input errors)

 

 

Methods:

  

      - New()     // Constructor

 

      - Chr( nCode )               // return string with nCode Unicode/ANSI character

      - Char( nCode )              // return string with nCode Unicode/ANSI character

      - Asc( cString )             // return Unicode/ANSI value of 1-st character (not byte) in given string

      - Code( cString )            // return Unicode/ANSI value of 1-st character (not byte) in given string

      - Len( cString )             // return string length in characters

      - ByteLen( cString )         // return string length in bytes

      - Peek( cString, n )         // return unicode value of <n>-th character in given string

      - Poke( cString, n, nVal )   // change <n>-th character in given string to unicode <nVal> one and return modified text

      - SubStr( cString, nStart, nCount )

      - Left( cString, nCount )

      - Right( cString, nCount )

      - At( cSubString, cString, nFrom, nTo )

      - Rat( cSearch, cTarget )

      - Stuff( cString, nStart, nDelete, cInsert )

        

      - BLen( cString )            // return string length in bytes

      - BLeft( cString, nCount  )

      - BRight( cString, nCount )

      - BSubStr( cString, nStart, nCount )

 

      - LTrim( cString )

      - RTrim( cString )

      - AllTrim( cString )

      - StrTran( cString, cSearch, cReplace, nStart, nCount )

      - Replicate( cString, nCount )

      - Space( nCount )

 

      - StrToUTF8( cStr, cCPID )

      - UTF8ToStr( cUTF8Str, cCPID )

      - IsUTF8( cString )

 

      - EOL()           // CR+LF

      - OsNewLine()     // CR+LF

 

      - Lower( cString )

      - Upper( cString )

      - PadC( cString, nLength, cFillChar )

      - PadL( cString, nLength, cFillChar )

      - PadR( cString, nLength, cFillChar )

      - IsAlpha( cString )

      - IsDigit( cString )

      - IsLower( cString )

      - IsUpper( cString )

      - IsAlphaNumeric( cString )  // return (ISALPHA(c) .OR. ISDIGIT(c))

 

      - StrCmp( cString1, cString2, lCaseSensitive ) // return -1 (minor), 0 (equal) , +1 (great)

 

 

Sample:

  

- For default HMG create an instance of this class, to access this instance with pseudovariable oString, e.g.

 

oString:Len( cString )

oString:Upper( cString )

 

- You create a new instance of this class with pseudofunction:

 

            oMyStr := HMG_TStringNew()   // this pseudofunction call the constructor method HMG_TString():New()

           

and use, e.g.

 

oMyStr:Len ( cString )

oMyStr:Upper( cString )