not ISOEM(), ISANSI() or IsUTF8()

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby Jimmy » Wed Aug 30, 2023 10:15 am

hi,

try this CODE and use your "UMLOEM.DBF"

Code: Select all  Expand view  RUN
#include "fivewin.ch"
#include "DBSTRUCT.CH"
#include "DrXlsx.ch"

* #define Use_OEM
#define Use_UTF8_Sign

REQUEST DBFCDX

*+--------------------------------------------------------------------
*+
*+    Function Main()
*+
*+--------------------------------------------------------------------
*+
FUNCTION Main( cDBF, cCodepage, cXLS )

LOCAL cLangCode := "DE"

   DEFAULT cDBF := "TESTTYPE.DBF"
   * DEFAULT cCodepage := "DE850"
   DEFAULT cCodepage := "DEWIN"
   DEFAULT cXLS := "DBF2EX.XLSX"

   SET DATE GERMAN
   SET EPOCH TO YEAR( DATE() ) - 50
   SET CENTURY ON
   SET DECIMALS TO 2

*   hb_LangSelect( cLangCode )
*   hb_cdpSelect( cCodepage )
*   FW_SetUnicode( .T. )

    UseDbf2Excel( cDBF, cCodepage, cXLS )

RETURN NIL

*+--------------------------------------------------------------------
*+
*+    Function UseDbf2Excel()
*+
*+    Called from ( xlswrite.prg )   1 - function main()
*+
*+--------------------------------------------------------------------
*+
FUNCTION UseDbf2Excel( cDBF, cCodepage, cXLS )
LOCAL oXlsx := TDrXlsx() :New()
LOCAL aStruct, ii, iMax, nRow, nCol, nReccount, cText1, cText2
LOCAL xValue, cType, nStart, nStop, nRecSec, nTime, cName, nLen
LOCAL nOEM       := 0
LOCAL nANSI      := 0
LOCAL nELSE      := 0
LOCAL nCount     := 0
LOCAL lDiverse   := .F.
LOCAL cFieldKDNR := ""
LOCAL nMemory
LOCAL nEvery
LOCAL nRecLast

   IF !FILE( cDBF )
      MsgInfo( "need DBF" )
   ENDIF

   IF FILE( "DBF2EX.XLSX" )
      FERASE( "DBF2EX.XLSX" )
   ENDIF

   USE (cDBF)                        // CODEPAGE cCodepage EXCLUSIVE
   aStruct := DBSTRUCT()
   iMax := LEN( aStruct )
   nReccount := RECCOUNT()
   nEvery := INT( nReccount / 100 )

fwlog cDBF, nReccount, iMax

   oXlsx:CreateFile( cXLS )

   nRow := 0
   FOR ii := 1 TO iMax
      nCol := ii - 1
      cName := aStruct[ ii ] [ DBS_NAME ]
      nLen  := aStruct[ ii ] [ DBS_LEN ] * 2
      cType := aStruct[ ii ] [ DBS_TYPE ]

      oXlsx:SetColumnSize( nRow, nCol, nLen )
      oXlsx:Say( nRow, nCol, cName )
fwlog nCol, cType, nLen, cName
   NEXT

   nCol := 0
   nRow := 1
   nStart := SECONDS()
   DO WHILE !EOF()

      MEMORY( - 1 )
      SysRefresh()

      nMemory := MEMORY( 3 )
      IF nMemory < 32000                                              // 32 kb
         fwlog "Memory(3)", RECNO(), MEMORY( 3 )
         EXIT
      ENDIF

      IF ( RECNO() % nEvery ) = 0
         nCount ++
         fwlog nCount, RECNO(), MEMORY( 3 )
      ENDIF

      ii := 1
      FOR ii := 1 TO iMax
         xValue := FIELDGET( ii )
         cName := TRIM( aStruct[ ii ] [ DBS_NAME ] )
         cType := TRIM( aStruct[ ii ] [ DBS_TYPE ] )
         nCol := ii - 1

         DO CASE
            CASE cType = "C"

               DO CASE
                  CASE ISOEM( xValue )
                     nOEM ++
                     // fwlog "ISOEM"
                     cText1 := Umlaute( xValue )
                     cText2 := CheckValue( cText1 )
                     IF !EMPTY( cText1 ) .AND. !EMPTY( cText2 )
                        oXlsx:Say( nRow, nCol, cText2 )
                     ENDIF

                  CASE ISANSI( xValue )
                     nANSI ++
                     // fwlog "ISANSI"
                     cText1 := Umlaute( xValue )
                     cText2 := CheckValue( cText1 )
                     IF !EMPTY( cText1 ) .AND. !EMPTY( cText2 )
                        oXlsx:Say( nRow, nCol, cText2 )
                     ENDIF

                  CASE IsUTF8( xValue )
                     fwlog "IsUTF8"
                     oXlsx:Say( nRow, nCol, xValue )
                  OTHERWISE
                     //  fwlog "ELSE", xValue
                     nELSE ++
                     oXlsx:Say( nRow, nCol, xValue )
               ENDCASE

            CASE cType = "M"
#ifdef Use_Memo
               cText1 := Umlaute( xValue )
               cText2 := CheckValue( cText1 )
               IF !EMPTY( cText2 )
                  oXlsx:WriteString( nRow, nCol, cText2 )
               ENDIF
#endif
            CASE cType = "N"
               oXlsx:WriteNumber( nRow, nCol, xValue )

            CASE cType = "D"
               oXlsx:WriteDate( nRow, nCol, xValue, DRXLSX_ALIGN_CENTER, "dd.mm.yyyy" )

            CASE cType = "L"
               oXlsx:WriteLogical( nRow, nCol, xValue, DRXLSX_ALIGN_CENTER )

               // CASE cType = "DT"
               //     oXlsx:Say(nRow,nCol,"Datetime format" )
               // CASE cType = "D+"
               //     oXlsx:Say(nRow,nCol,"Datetime" )
         ENDCASE

      NEXT
      SKIP
      nRow ++
   ENDDO

   oXlsx:Close()
   nStop := SECONDS()
   nTime := ( nStop - nStart )

   nRecLast := RECNO()
   nRecSec := nRecLast / nTime

fwlog nReccount, nRecLast, nCount, nTime, nRecSec, nOEM, nANSI, nELSE

   IF USED()
      CLOSE
   ENDIF

   MEMORY( - 1 )
   SysRefresh()

RETURN NIL

*+--------------------------------------------------------------------
*+
*+    Function Umlaute()
*+
*+    Called from ( xlswrite.prg )   4 - function usedbf2excel()
*+
*+--------------------------------------------------------------------
*+
FUNCTION Umlaute( cIn, nNo )
LOCAL cText := TRIM( cIn )
LOCAL cTest1, cTest2

   cTest1 := UTF16toUTF8( strToWide( UML_OEMTOANSI( cText ) ) )

#ifdef Use_UTF8_Sign
   cText := STRTRAN( cText, CHR( 228 ), "ä" )
   cText := STRTRAN( cText, CHR( 246 ), "ö" )
   cText := STRTRAN( cText, CHR( 252 ), "ü" )

   cText := STRTRAN( cText, CHR( 196 ), "Ä" )
   cText := STRTRAN( cText, CHR( 214 ), "Ö" )
   cText := STRTRAN( cText, CHR( 220 ), "Ü" )

   cText := STRTRAN( cText, CHR( 223 ), "ß" )
#endif

cTest2 := cText

#ifdef Use_OEM
   // OEM
   cText := STRTRAN( cText, CHR( 132 ), "ä" )
   cText := STRTRAN( cText, CHR( 148 ), "ö" )
   cText := STRTRAN( cText, CHR( 129 ), "ü" )

   cText := STRTRAN( cText, CHR( 142 ), "Ä" )
   cText := STRTRAN( cText, CHR( 153 ), "Ö" )
   cText := STRTRAN( cText, CHR( 154 ), "Ü" )

   cText := STRTRAN( cText, CHR( 225 ), "ß" )
#endif

fwlog cText, cTest1, cTest2, cTest1 == cTest2

RETURN cText

*+--------------------------------------------------------------------
*+
*+    Function CheckValue()
*+
*+    Called from ( xlswrite.prg )   4 - function usedbf2excel()
*+
*+--------------------------------------------------------------------
*+
FUNCTION CheckValue( xValue )
LOCAL lNoCheck := .F.
LOCAL cRet     := ""
LOCAL aSign    := "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+/.,:;!$%&/()=?#"
LOCAL cSign, ii, iMax, cLine := TRIM( xValue )

#ifdef Use_UTF8_Sign
   aSign += "äöüÄÖÜß"
#endif
   aSign += CHR( 34 )

   IF lNoCheck = .T.
      cRet := cLine
   ELSE
      iMax := LEN( cLine )
      FOR ii := 1 TO iMax
         cSign := SUBSTR( cLine, ii, 1 )
         //       IF AT(cSign,cLine) > 0
         IF cSign $ aSign
            cRet += cSign
         ELSE
fwlog cSign, ASC( cSign ), cRet
            cRet := ""
            EXIT
         ENDIF
      NEXT
   ENDIF

RETURN cRet
 

save as UTF8 Format
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby nageswaragunupudi » Wed Aug 30, 2023 2:23 pm

YES this "seems" to work, no Error in LOG :D

but when try to open Excel Sheet i got Warning and all Type "C" are empty ... :shock:



This is the test I made.
Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local cOemHex  := "8494818E999AE1"
   local cOemText, c, oXlsx
   local cFileXls := "UMLDRXL.XLSX"

   cOemText    := HEXTOSTR( cOemHex )

   oXlsx := TDrXlsx():New()
   WITH OBJECT oXlsx
      :CreateFile( cFileXls )
      :SetColumnSize( 0, 0, 80 )
      :WriteString( 0, 0, Utf16toUtf8( strToWide( UML_OemToAnsi( cOemText ) ) ) )
      c  := "abcd" + Left( cOemText, 4 ) + "pqr" + Right( cOemText, 3 ) + "xyz"
      :WriteString( 1, 0, Utf16toUtf8( strToWide( UML_OemToAnsi( c ) ) ) )

      :Close()
   END

   ShellExecute( 0, "Open", cFileXls )

return nil

#pragma BEGINDUMP

#include <hbapi.h>

HB_FUNC( UML_OEMTOANSI )
{
unsigned char achar[] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,
29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,
54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,
79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,
103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,
122,123,124,125,126,127,128,252,130,131,228,133,134,135,136,137,138,139,140,
141,196,143,144,145,146,147,246,149,150,151,152,214,220,155,156,157,158,159,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,
179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,
198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,
217,218,219,220,221,222,223,224,223,226,227,228,229,230,231,232,233,234,235,
236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,
255 };

   char * pText = ( char * ) hb_parc( 1 );
   int iLen = hb_parclen( 1 );
   int i;
   unsigned char c;

   for ( i = 0; i < iLen; i++ )
   {
      c = pText[ i ];
      pText[ i ] = achar[ c ];
   }

   hb_retc( pText );
}
#pragma ENDDUMP
 


Image

If you run this test as it is you will also see that these conversions work well with Drxlsx as well as Excel.

When you use these functions directly on your DBF, it fails. That should be expected.
Reason:
As I said earlier, converting only the 7 umlaut characters is NOT enough at all.
This kind of conversion, we need to do for all accented characters of German language.
That is the reason I requested you to prepare a list of all such characters and provide us and then we will work out a correct conversion function.

The only foreign language I know is English whose characters are the same in OEM, ANSI and UTF8.
Because I do not know German, we need your help.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby Jimmy » Wed Aug 30, 2023 3:17 pm

hi,
nageswaragunupudi wrote:When you use these functions directly on your DBF, it fails. That should be expected.
Reason:
As I said earlier, converting only the 7 umlaut characters is NOT enough at all.
This kind of conversion, we need to do for all accented characters of German language.
That is the reason I requested you to prepare a list of all such characters and provide us and then we will work out a correct conversion function.

The only foreign language I know is English whose characters are the same in OEM, ANSI and UTF8.
Because I do not know German, we need your help.

i do not understand which Sign you mean with Accent :?: do you mean Sign > CHR(128) :?:

---

when look at last Sample i do compare both Sting where Test1 == Test2
but
Code: Select all  Expand view  RUN
  Test1 := Utf16toUtf8( strToWide( UML_OemToAnsi( cOemText ) ) ) )

fail while
Code: Select all  Expand view  RUN
   cText := STRTRAN( cText, CHR( 228 ), "ä" )
   cText := STRTRAN( cText, CHR( 246 ), "ö" )
   cText := STRTRAN( cText, CHR( 252 ), "ü" )
   cText := STRTRAN( cText, CHR( 196 ), "Ä" )
   cText := STRTRAN( cText, CHR( 214 ), "Ö" )
   cText := STRTRAN( cText, CHR( 220 ), "Ü" )
   cText := STRTRAN( cText, CHR( 223 ), "ß" )

   cTest2 := cText

WORK

cText = "ääääääääää" cTest1 = "ääääääääää" cTest2 = "ääääääääää" cTest1 == cTest2 = .T.
cText = "öööööööööö" cTest1 = "öööööööööö" cTest2 = "öööööööööö" cTest1 == cTest2 = .T.
cText = "üüüüüüüüüü" cTest1 = "üüüüüüüüüü" cTest2 = "üüüüüüüüüü" cTest1 == cTest2 = .T.
cText = "ÄÄÄÄÄÄÄÄÄ" cTest1 = "ÄÄÄÄÄÄÄÄÄ" cTest2 = "ÄÄÄÄÄÄÄÄÄ" cTest1 == cTest2 = .T.
cText = "ÖÖÖÖÖÖÖÖÖÖ" cTest1 = "ÖÖÖÖÖÖÖÖÖÖ" cTest2 = "ÖÖÖÖÖÖÖÖÖÖ" cTest1 == cTest2 = .T.
cText = "ÜÜÜÜÜÜÜÜÜÜ" cTest1 = "ÜÜÜÜÜÜÜÜÜÜ" cTest2 = "ÜÜÜÜÜÜÜÜÜÜ" cTest1 == cTest2 = .T.
cText = "ßßßßßßßßßß" cTest1 = "ßßßßßßßßßß" cTest2 = "ßßßßßßßßßß" cTest1 == cTest2 = .T.
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby Jimmy » Wed Aug 30, 2023 3:46 pm

hi,

here are German Sign from 32 to 255
STRTOHEX( cSign ) = "20" ASC( cSign ) = 32
STRTOHEX( cSign ) = "21" ASC( cSign ) = 33
STRTOHEX( cSign ) = "22" ASC( cSign ) = 34
STRTOHEX( cSign ) = "23" ASC( cSign ) = 35
STRTOHEX( cSign ) = "24" ASC( cSign ) = 36
STRTOHEX( cSign ) = "25" ASC( cSign ) = 37
STRTOHEX( cSign ) = "26" ASC( cSign ) = 38
STRTOHEX( cSign ) = "27" ASC( cSign ) = 39
STRTOHEX( cSign ) = "28" ASC( cSign ) = 40
STRTOHEX( cSign ) = "29" ASC( cSign ) = 41
STRTOHEX( cSign ) = "2A" ASC( cSign ) = 42
STRTOHEX( cSign ) = "2B" ASC( cSign ) = 43
STRTOHEX( cSign ) = "2C" ASC( cSign ) = 44
STRTOHEX( cSign ) = "2D" ASC( cSign ) = 45
STRTOHEX( cSign ) = "2E" ASC( cSign ) = 46
STRTOHEX( cSign ) = "2F" ASC( cSign ) = 47
STRTOHEX( cSign ) = "30" ASC( cSign ) = 48
STRTOHEX( cSign ) = "31" ASC( cSign ) = 49
STRTOHEX( cSign ) = "32" ASC( cSign ) = 50
STRTOHEX( cSign ) = "33" ASC( cSign ) = 51
STRTOHEX( cSign ) = "34" ASC( cSign ) = 52
STRTOHEX( cSign ) = "35" ASC( cSign ) = 53
STRTOHEX( cSign ) = "36" ASC( cSign ) = 54
STRTOHEX( cSign ) = "37" ASC( cSign ) = 55
STRTOHEX( cSign ) = "38" ASC( cSign ) = 56
STRTOHEX( cSign ) = "39" ASC( cSign ) = 57
STRTOHEX( cSign ) = "3A" ASC( cSign ) = 58
STRTOHEX( cSign ) = "3B" ASC( cSign ) = 59
STRTOHEX( cSign ) = "3C" ASC( cSign ) = 60
STRTOHEX( cSign ) = "3D" ASC( cSign ) = 61
STRTOHEX( cSign ) = "3E" ASC( cSign ) = 62
STRTOHEX( cSign ) = "3F" ASC( cSign ) = 63
STRTOHEX( cSign ) = "40" ASC( cSign ) = 64
STRTOHEX( cSign ) = "41" ASC( cSign ) = 65
STRTOHEX( cSign ) = "42" ASC( cSign ) = 66
STRTOHEX( cSign ) = "43" ASC( cSign ) = 67
STRTOHEX( cSign ) = "44" ASC( cSign ) = 68
STRTOHEX( cSign ) = "45" ASC( cSign ) = 69
STRTOHEX( cSign ) = "46" ASC( cSign ) = 70
STRTOHEX( cSign ) = "47" ASC( cSign ) = 71
STRTOHEX( cSign ) = "48" ASC( cSign ) = 72
STRTOHEX( cSign ) = "49" ASC( cSign ) = 73
STRTOHEX( cSign ) = "4A" ASC( cSign ) = 74
STRTOHEX( cSign ) = "4B" ASC( cSign ) = 75
STRTOHEX( cSign ) = "4C" ASC( cSign ) = 76
STRTOHEX( cSign ) = "4D" ASC( cSign ) = 77
STRTOHEX( cSign ) = "4E" ASC( cSign ) = 78
STRTOHEX( cSign ) = "4F" ASC( cSign ) = 79
STRTOHEX( cSign ) = "50" ASC( cSign ) = 80
STRTOHEX( cSign ) = "51" ASC( cSign ) = 81
STRTOHEX( cSign ) = "52" ASC( cSign ) = 82
STRTOHEX( cSign ) = "53" ASC( cSign ) = 83
STRTOHEX( cSign ) = "54" ASC( cSign ) = 84
STRTOHEX( cSign ) = "55" ASC( cSign ) = 85
STRTOHEX( cSign ) = "56" ASC( cSign ) = 86
STRTOHEX( cSign ) = "57" ASC( cSign ) = 87
STRTOHEX( cSign ) = "58" ASC( cSign ) = 88
STRTOHEX( cSign ) = "59" ASC( cSign ) = 89
STRTOHEX( cSign ) = "5A" ASC( cSign ) = 90
STRTOHEX( cSign ) = "5B" ASC( cSign ) = 91
STRTOHEX( cSign ) = "5C" ASC( cSign ) = 92
STRTOHEX( cSign ) = "5D" ASC( cSign ) = 93
STRTOHEX( cSign ) = "5E" ASC( cSign ) = 94
STRTOHEX( cSign ) = "5F" ASC( cSign ) = 95
STRTOHEX( cSign ) = "60" ASC( cSign ) = 96
STRTOHEX( cSign ) = "61" ASC( cSign ) = 97
STRTOHEX( cSign ) = "62" ASC( cSign ) = 98
STRTOHEX( cSign ) = "63" ASC( cSign ) = 99
STRTOHEX( cSign ) = "64" ASC( cSign ) = 100
STRTOHEX( cSign ) = "65" ASC( cSign ) = 101
STRTOHEX( cSign ) = "66" ASC( cSign ) = 102
STRTOHEX( cSign ) = "67" ASC( cSign ) = 103
STRTOHEX( cSign ) = "68" ASC( cSign ) = 104
STRTOHEX( cSign ) = "69" ASC( cSign ) = 105
STRTOHEX( cSign ) = "6A" ASC( cSign ) = 106
STRTOHEX( cSign ) = "6B" ASC( cSign ) = 107
STRTOHEX( cSign ) = "6C" ASC( cSign ) = 108
STRTOHEX( cSign ) = "6D" ASC( cSign ) = 109
STRTOHEX( cSign ) = "6E" ASC( cSign ) = 110
STRTOHEX( cSign ) = "6F" ASC( cSign ) = 111
STRTOHEX( cSign ) = "70" ASC( cSign ) = 112
STRTOHEX( cSign ) = "71" ASC( cSign ) = 113
STRTOHEX( cSign ) = "72" ASC( cSign ) = 114
STRTOHEX( cSign ) = "73" ASC( cSign ) = 115
STRTOHEX( cSign ) = "74" ASC( cSign ) = 116
STRTOHEX( cSign ) = "75" ASC( cSign ) = 117
STRTOHEX( cSign ) = "76" ASC( cSign ) = 118
STRTOHEX( cSign ) = "77" ASC( cSign ) = 119
STRTOHEX( cSign ) = "78" ASC( cSign ) = 120
STRTOHEX( cSign ) = "79" ASC( cSign ) = 121
STRTOHEX( cSign ) = "7A" ASC( cSign ) = 122
STRTOHEX( cSign ) = "7B" ASC( cSign ) = 123
STRTOHEX( cSign ) = "7C" ASC( cSign ) = 124
STRTOHEX( cSign ) = "7D" ASC( cSign ) = 125
STRTOHEX( cSign ) = "7E" ASC( cSign ) = 126
STRTOHEX( cSign ) = "7F" ASC( cSign ) = 127
STRTOHEX( cSign ) = "80" ASC( cSign ) = 128
STRTOHEX( cSign ) = "81" ASC( cSign ) = 129
STRTOHEX( cSign ) = "82" ASC( cSign ) = 130
STRTOHEX( cSign ) = "83" ASC( cSign ) = 131
STRTOHEX( cSign ) = "84" ASC( cSign ) = 132
STRTOHEX( cSign ) = "85" ASC( cSign ) = 133
STRTOHEX( cSign ) = "86" ASC( cSign ) = 134
STRTOHEX( cSign ) = "87" ASC( cSign ) = 135
STRTOHEX( cSign ) = "88" ASC( cSign ) = 136
STRTOHEX( cSign ) = "89" ASC( cSign ) = 137
STRTOHEX( cSign ) = "8A" ASC( cSign ) = 138
STRTOHEX( cSign ) = "8B" ASC( cSign ) = 139
STRTOHEX( cSign ) = "8C" ASC( cSign ) = 140
STRTOHEX( cSign ) = "8D" ASC( cSign ) = 141
STRTOHEX( cSign ) = "8E" ASC( cSign ) = 142
STRTOHEX( cSign ) = "8F" ASC( cSign ) = 143
STRTOHEX( cSign ) = "90" ASC( cSign ) = 144
STRTOHEX( cSign ) = "91" ASC( cSign ) = 145
STRTOHEX( cSign ) = "92" ASC( cSign ) = 146
STRTOHEX( cSign ) = "93" ASC( cSign ) = 147
STRTOHEX( cSign ) = "94" ASC( cSign ) = 148
STRTOHEX( cSign ) = "95" ASC( cSign ) = 149
STRTOHEX( cSign ) = "96" ASC( cSign ) = 150
STRTOHEX( cSign ) = "97" ASC( cSign ) = 151
STRTOHEX( cSign ) = "98" ASC( cSign ) = 152
STRTOHEX( cSign ) = "99" ASC( cSign ) = 153
STRTOHEX( cSign ) = "9A" ASC( cSign ) = 154
STRTOHEX( cSign ) = "9B" ASC( cSign ) = 155
STRTOHEX( cSign ) = "9C" ASC( cSign ) = 156
STRTOHEX( cSign ) = "9D" ASC( cSign ) = 157
STRTOHEX( cSign ) = "9E" ASC( cSign ) = 158
STRTOHEX( cSign ) = "9F" ASC( cSign ) = 159
STRTOHEX( cSign ) = "A0" ASC( cSign ) = 160
STRTOHEX( cSign ) = "A1" ASC( cSign ) = 161
STRTOHEX( cSign ) = "A2" ASC( cSign ) = 162
STRTOHEX( cSign ) = "A3" ASC( cSign ) = 163
STRTOHEX( cSign ) = "A4" ASC( cSign ) = 164
STRTOHEX( cSign ) = "A5" ASC( cSign ) = 165
STRTOHEX( cSign ) = "A6" ASC( cSign ) = 166
STRTOHEX( cSign ) = "A7" ASC( cSign ) = 167
STRTOHEX( cSign ) = "A8" ASC( cSign ) = 168
STRTOHEX( cSign ) = "A9" ASC( cSign ) = 169
STRTOHEX( cSign ) = "AA" ASC( cSign ) = 170
STRTOHEX( cSign ) = "AB" ASC( cSign ) = 171
STRTOHEX( cSign ) = "AC" ASC( cSign ) = 172
STRTOHEX( cSign ) = "AD" ASC( cSign ) = 173
STRTOHEX( cSign ) = "AE" ASC( cSign ) = 174
STRTOHEX( cSign ) = "AF" ASC( cSign ) = 175
STRTOHEX( cSign ) = "B0" ASC( cSign ) = 176
STRTOHEX( cSign ) = "B1" ASC( cSign ) = 177
STRTOHEX( cSign ) = "B2" ASC( cSign ) = 178
STRTOHEX( cSign ) = "B3" ASC( cSign ) = 179
STRTOHEX( cSign ) = "B4" ASC( cSign ) = 180
STRTOHEX( cSign ) = "B5" ASC( cSign ) = 181
STRTOHEX( cSign ) = "B6" ASC( cSign ) = 182
STRTOHEX( cSign ) = "B7" ASC( cSign ) = 183
STRTOHEX( cSign ) = "B8" ASC( cSign ) = 184
STRTOHEX( cSign ) = "B9" ASC( cSign ) = 185
STRTOHEX( cSign ) = "BA" ASC( cSign ) = 186
STRTOHEX( cSign ) = "BB" ASC( cSign ) = 187
STRTOHEX( cSign ) = "BC" ASC( cSign ) = 188
STRTOHEX( cSign ) = "BD" ASC( cSign ) = 189
STRTOHEX( cSign ) = "BE" ASC( cSign ) = 190
STRTOHEX( cSign ) = "BF" ASC( cSign ) = 191
STRTOHEX( cSign ) = "C0" ASC( cSign ) = 192
STRTOHEX( cSign ) = "C1" ASC( cSign ) = 193
STRTOHEX( cSign ) = "C2" ASC( cSign ) = 194
STRTOHEX( cSign ) = "C3" ASC( cSign ) = 195
STRTOHEX( cSign ) = "C4" ASC( cSign ) = 196
STRTOHEX( cSign ) = "C5" ASC( cSign ) = 197
STRTOHEX( cSign ) = "C6" ASC( cSign ) = 198
STRTOHEX( cSign ) = "C7" ASC( cSign ) = 199
STRTOHEX( cSign ) = "C8" ASC( cSign ) = 200
STRTOHEX( cSign ) = "C9" ASC( cSign ) = 201
STRTOHEX( cSign ) = "CA" ASC( cSign ) = 202
STRTOHEX( cSign ) = "CB" ASC( cSign ) = 203
STRTOHEX( cSign ) = "CC" ASC( cSign ) = 204
STRTOHEX( cSign ) = "CD" ASC( cSign ) = 205
STRTOHEX( cSign ) = "CE" ASC( cSign ) = 206
STRTOHEX( cSign ) = "CF" ASC( cSign ) = 207
STRTOHEX( cSign ) = "D0" ASC( cSign ) = 208
STRTOHEX( cSign ) = "D1" ASC( cSign ) = 209
STRTOHEX( cSign ) = "D2" ASC( cSign ) = 210
STRTOHEX( cSign ) = "D3" ASC( cSign ) = 211
STRTOHEX( cSign ) = "D4" ASC( cSign ) = 212
STRTOHEX( cSign ) = "D5" ASC( cSign ) = 213
STRTOHEX( cSign ) = "D6" ASC( cSign ) = 214
STRTOHEX( cSign ) = "D7" ASC( cSign ) = 215
STRTOHEX( cSign ) = "D8" ASC( cSign ) = 216
STRTOHEX( cSign ) = "D9" ASC( cSign ) = 217
STRTOHEX( cSign ) = "DA" ASC( cSign ) = 218
STRTOHEX( cSign ) = "DB" ASC( cSign ) = 219
STRTOHEX( cSign ) = "DC" ASC( cSign ) = 220
STRTOHEX( cSign ) = "DD" ASC( cSign ) = 221
STRTOHEX( cSign ) = "DE" ASC( cSign ) = 222
STRTOHEX( cSign ) = "DF" ASC( cSign ) = 223
STRTOHEX( cSign ) = "E0" ASC( cSign ) = 224
STRTOHEX( cSign ) = "E1" ASC( cSign ) = 225
STRTOHEX( cSign ) = "E2" ASC( cSign ) = 226
STRTOHEX( cSign ) = "E3" ASC( cSign ) = 227
STRTOHEX( cSign ) = "E4" ASC( cSign ) = 228
STRTOHEX( cSign ) = "E5" ASC( cSign ) = 229
STRTOHEX( cSign ) = "E6" ASC( cSign ) = 230
STRTOHEX( cSign ) = "E7" ASC( cSign ) = 231
STRTOHEX( cSign ) = "E8" ASC( cSign ) = 232
STRTOHEX( cSign ) = "E9" ASC( cSign ) = 233
STRTOHEX( cSign ) = "EA" ASC( cSign ) = 234
STRTOHEX( cSign ) = "EB" ASC( cSign ) = 235
STRTOHEX( cSign ) = "EC" ASC( cSign ) = 236
STRTOHEX( cSign ) = "ED" ASC( cSign ) = 237
STRTOHEX( cSign ) = "EE" ASC( cSign ) = 238
STRTOHEX( cSign ) = "EF" ASC( cSign ) = 239
STRTOHEX( cSign ) = "F0" ASC( cSign ) = 240
STRTOHEX( cSign ) = "F1" ASC( cSign ) = 241
STRTOHEX( cSign ) = "F2" ASC( cSign ) = 242
STRTOHEX( cSign ) = "F3" ASC( cSign ) = 243
STRTOHEX( cSign ) = "F4" ASC( cSign ) = 244
STRTOHEX( cSign ) = "F5" ASC( cSign ) = 245
STRTOHEX( cSign ) = "F6" ASC( cSign ) = 246
STRTOHEX( cSign ) = "F7" ASC( cSign ) = 247
STRTOHEX( cSign ) = "F8" ASC( cSign ) = 248
STRTOHEX( cSign ) = "F9" ASC( cSign ) = 249
STRTOHEX( cSign ) = "FA" ASC( cSign ) = 250
STRTOHEX( cSign ) = "FB" ASC( cSign ) = 251
STRTOHEX( cSign ) = "FC" ASC( cSign ) = 252
STRTOHEX( cSign ) = "FD" ASC( cSign ) = 253
STRTOHEX( cSign ) = "FE" ASC( cSign ) = 254
STRTOHEX( cSign ) = "FF" ASC( cSign ) = 255
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby nageswaragunupudi » Wed Aug 30, 2023 5:26 pm

That is just a list from 33 to 255.
I am looking for German OEM character codes, of "characters having accent"
Its ok. Please leave it.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby nageswaragunupudi » Wed Aug 30, 2023 7:02 pm

May I ask about your oem.dbf?

1. Does this code display the text correctly or correctly in most of the cases?
Code: Select all  Expand view  RUN
XBROWSER "name.dbf" SETUP ( oBrw:lOemAnsi := .t. )

or
Code: Select all  Expand view  RUN
USE <name.dbf>
XBROWSER ALIAS() SETUP ( oBrw:lOemAnsi := .t.  )

Does changing Codepages make much difference?

2. How large is the dbf? Number of records and number of fields?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby nageswaragunupudi » Thu Aug 31, 2023 4:11 am

After doing several tests, I came to the opinion that it is not a good idea to make our functions. It is better to depend on the standard Harbour function OemToAnsi() and then later convert to Utf8 if necessary.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby Jimmy » Thu Aug 31, 2023 6:13 am

hi,
nageswaragunupudi wrote:May I ask about your oem.dbf?

have send you a Email with Link to my Online-Web-Space where i have upload "DE_OEM.ZIP"

nageswaragunupudi wrote:1. Does this code display the text correctly or correctly in most of the cases?
Code: Select all  Expand view  RUN
XBROWSER "name.dbf" SETUP ( oBrw:lOemAnsi := .t. )

or
Code: Select all  Expand view  RUN
USE <name.dbf>
XBROWSER ALIAS() SETUP ( oBrw:lOemAnsi := .t.  )

will test it

nageswaragunupudi wrote:Does changing Codepages make much difference?

when Codepage is wrong German "Umlaute" does not Display / Print
it are those 7 "Umlaute" only ( German does not use "accent" Sign )

nageswaragunupudi wrote:2. How large is the dbf? Number of records and number of fields?

Size < 1 Kb, 255-32 Records, 1 x FIELD
RECNO() -> CHR(x)
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby nageswaragunupudi » Thu Aug 31, 2023 6:57 am

have send you a Email with Link to my Online-Web-Space where i have upload "DE_OEM.ZIP"

I did not receive it yet.

email:
nageswaragunupudi [@] gmail [dot] com
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby nageswaragunupudi » Thu Aug 31, 2023 5:34 pm

German does not use "accent" Sign


I am asking out of ignorance.
Are these not German characters?

õòóôûúùâáàãêéèÃÁÀ

I typed these characters using Google Virtual Keyboard for German Language
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby nageswaragunupudi » Thu Aug 31, 2023 6:43 pm

Size < 1 Kb, 255-32 Records, 1 x FIELD
RECNO() -> CHR(x)


This is the code for 255-32 records
Code: Select all  Expand view  RUN
function Chars33to255()

   local oXlsx
   local cFile := "chars33to255.xlsx"
   local n,na, c, cx

   ? "Start"
   oXlsx := TDrXlsx():New()
   oXlsx:CreateFile( cFile )
   oXlsx:SetColumnSize( 0, 3, 8 )

   for n := 33 to 255
      oXlsx:WriteNumber( n - 33, 0, n )
      c  := Chr( n )
      if IsOem( c )
         c  := OemToAnsi( c )
      endif
      oXlsx:WriteNumber( n - 33, 1, ASC( c ) )
      c  := HB_UTF8CHR( ASC( c ) )
      oXlsx:WriteString( n - 33, 2, STRTOHEX( c ) )
      oXlsx:WriteString( n - 33, 3, c )
   next

   oXlsx:Close()
   ? "Done"

   ShellExecute( 0, "Open", cFile )

return nil
 

No errors.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby Jimmy » Fri Sep 01, 2023 2:47 pm

hi,
nageswaragunupudi wrote:This is the code for 255-32 records

as long Sign come not from DBF, made in OEM Environment , it is not the Problem that i mean

as i say these OEM DBF was made by Cl*pper App, using NTX, where i have OEM Sign with German "Umlaute"

as Xbase++ default use OEM it is a Problem of all Xbase++ User when want to change to Fivewin (and still use Xbase++ OEM App)
i can change CODEPAGE to DE850 for OEM-DBF to display "right" under Fivewin but it does not "change" it to UFT8 which DrXlsx need

i will try to send you OEM-DBF again

---

i have found this OT4XB CODE
Code: Select all  Expand view  RUN
XPPRET XPPENTRY COEMTOUTF8(XppParamList pl )
{
   ContainerHandle conr = _conNew(NULLCONTAINER);
   BOOL bByRef = FALSE;
   ContainerHandle conc = _conTParam( pl,1,&bByRef,XPP_CHARACTER);
   if( conc )
   {
      ULONG nOemLen = 0;
      LPSTR pOem    = 0;
      if( ot4xb_conRLockC(conc,&pOem,&nOemLen) == 0 )
      {
         LPWSTR pWide    = (LPWSTR) _xgrab( (nOemLen * 2) + 2 );
         int    nWideLen = MultiByteToWideChar(CP_OEMCP,0,pOem,(int)nOemLen,pWide,(int)(nOemLen+1));
         int    nUtf8Len = WideCharToMultiByte(CP_UTF8,0,pWide,nWideLen,NULL,0,0,0);
         LPSTR  pUtf8    = (LPSTR) _xgrab((UINT) (nUtf8Len + 1));
         nUtf8Len = WideCharToMultiByte(CP_UTF8,0,pWide,nWideLen,pUtf8,nUtf8Len+1,0,0);
         _conPutCL(conr,pUtf8,(ULONG)nUtf8Len);
         ot4xb_conUnlockC(conc);
         _xfree( (void*) pWide ); _xfree( (void*) pUtf8 );
      }
      if(!bByRef ) _conRelease(conc);
      conc = 0;
   }
   _conReturn(pl,conr); _conRelease(conr);
}
 

Code: Select all  Expand view  RUN
OT4XB_API WCHAR * pAnsi2WStr( LPSTR pAnsi , int cb , int* pcc )
{
   if( pAnsi )
   {
      if( (cb == -1 ) && pAnsi ) cb = (int) _xstrlen(pAnsi);
      if( pAnsi && cb )
      {
         LPWSTR pWide = (LPWSTR) _xgrab( (ULONG) ((cb + 1) * 2) );
         int    cc    = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,pAnsi,cb,pWide,cb);
         if( pcc ) pcc[0] = cc;
         return pWide;
      }
   }
   return 0;
}
 

Code: Select all  Expand view  RUN
OT4XB_API LPSTR pWStr2Ansi( WCHAR* pWide  , int cc, int* pcc)
{
   if( pWide )
   {
      if( (cc == -1 ) && pWide ) cc = (int) _xstrlenW(pWide);
      if( pWide && cc )
      {
         LPSTR  pAnsi = (LPSTR) _xgrab( (ULONG) (cc + 1) );
         cc = WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK,pWide,cc,pAnsi,cc,0,0);
         if( pcc ) pcc[0] = cc;
         return pAnsi;
      }
   }
   return 0;
}
 

and reverse
Code: Select all  Expand view  RUN
XPPRET XPPENTRY CUTF8TOOEM(XppParamList pl )
{
   ContainerHandle conr = _conNew(NULLCONTAINER);
   BOOL bByRef = FALSE;
   ContainerHandle conc = _conTParam( pl,1,&bByRef,XPP_CHARACTER);
   if( conc )
   {
      ULONG nUtf8Len = 0;
      LPSTR pUtf8    = 0;
      if( ot4xb_conRLockC(conc,&pUtf8,&nUtf8Len) == 0 )
      {
         LPWSTR pWide    = (LPWSTR) _xgrab( (nUtf8Len * 2) + 2 );
         int    nWideLen = MultiByteToWideChar(CP_UTF8,0,pUtf8,(int)nUtf8Len,pWide,(int)(nUtf8Len+1));
         int    nOemLen = WideCharToMultiByte(CP_OEMCP,0,pWide,nWideLen,NULL,0,0,0);
         LPSTR  pOem    = (LPSTR) _xgrab((UINT) (nOemLen + 1));
         nOemLen = WideCharToMultiByte(CP_OEMCP,0,pWide,nWideLen,pOem,nOemLen+1,0,0);
         _conPutCL(conr,pOem,(ULONG)nOemLen);
         ot4xb_conUnlockC(conc);
         _xfree( (void*) pWide ); _xfree( (void*) pOem );
      }
      if(!bByRef ) _conRelease(conc);
      conc = 0;
   }
   _conReturn(pl,conr); _conRelease(conr);
}
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby nageswaragunupudi » Fri Sep 01, 2023 5:33 pm

as i say these OEM DBF was made by Cl*pper App, using NTX, where i have OEM Sign with German "Umlaute"

as Xbase++ default use OEM it is a Problem of all Xbase++ User when want to change to Fivewin (and still use Xbase++ OEM App)

If you can share such a real life OEM dbf with a few thousand records, we will try to see if we can find a way to make things easier for you.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby nageswaragunupudi » Fri Sep 01, 2023 5:35 pm

as long Sign come not from DBF, made in OEM Environment , it is not the Problem that i mean

It works the same way even if is from oem dbf.
If you see my earlier samples, I created OEM dbf with Umlauts and showed exporting them
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: not ISOEM(), ISANSI() or IsUTF8()

Postby Jimmy » Fri Sep 01, 2023 8:49 pm

hi,
nageswaragunupudi wrote:If you see my earlier samples, I created OEM dbf with Umlauts and showed exporting them

to say it again : i need "read" from existing DBF, NOT "made" it from CODE

i talk about DBF made under Cl*pper OEM / DOS which many Xbase++ User have as OEM is default

this Way Xbase++ User have used there old Cl*pper / DOS App and Xbase++ / Windows / GUI with "same" DBF
Xbase++ does "translate" OEM <-> ANSI "automatic" ( not all Language )

---

"normal" i just need to change CODEPAGE from "DEWIN" to "DE850" to display German "Umlaute" under harbour
than also "input" under harbour is right when look using Xbase++ App

"only" DrXlsx LIB need UTF8 where German "Umlaute" fail WHEN it come from German OEM DBF

---

Sample which i used have > 350000 Records but only 0,02 % have "Umlaute"
so i have to "test" every Record / FIELD Type "C" if it have "Umlaute"

Question : did you get Email with Link to "my" DBF :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 46 guests