Page 1 of 1

Working with dbf

PostPosted: Tue Jul 27, 2021 7:50 am
by Ruth
Dear friends,
our landingpage example works with dbfs.
Please can you help me: What is the difference between "Codifica ANSI" and "Codifica OEM".
Image

i have to use a lot of special characters and therefor have a function
Code: Select all  Expand view
function convertUmlaute( cVData )
    local ctest := ""
    local I := 0

// ´
cVData  :=  STRTRAN(cVData, chr(180), "´" )

// Ä
cVData  :=  STRTRAN(cVData, chr(196), "Ä"   )
 
// Ö
cVData  :=  STRTRAN(cVData, chr(214), "Ö"   )
 
// Ü
cVData  :=  STRTRAN(cVData, chr(220), "Ü" )
 
// ß
cVData  :=  STRTRAN(cVData, chr(223), "ß" )
 
// à
cVData  :=  STRTRAN(cVData, chr(224), "à" )
 
// á
cVData  :=  STRTRAN(cVData, chr(225), "á" )

// ä
cVData  :=  STRTRAN(cVData, chr(228), "ä"   )

// ö
cVData  :=  STRTRAN(cVData, chr(246), "ö"   )
 
// ü
cVData  :=  STRTRAN(cVData, chr(252), "ü"   )
   
return(cVData)

that is called for example from here:
Code: Select all  Expand view


use ( cTMPPage ) new ALIAS landingpage
logging( "close: " + cTMPPage   )
Close
use ( cTMPPage ) new ALIAS landingpage

index on field->ID  TAG TmpB5Nr TO TEMP5 TEMPORARY
do while .not. eof()
  if field->ready = .T.
   if field->LANGUAGE  = cPage
      nRecords += 1
      AADD( aRelationship_DBF, ( "REC" + "_" + ALLTRIM( STR( nRecords ) ) + "_"  )  )

     if VALTYPE( field->ID ) = "N"
        hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_ID" ] = ALLTRIM( field->ID )  
     
     elseif VALTYPE( field->ID ) = "D"
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR(nRecords ) ) +"_ID" ] = dtoc( field->ID )  
     
      elseif VALTYPE( field->ID ) = "C"  .or. VALTYPE( field->ID ) = "M"
         if LEN( ALLTRIM( field->ID ) ) = 0
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_ID" ] = ALLTRIM( field->ID )
         else
            hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_ID" ] = ALLTRIM( CONVERTUMLAUTE (  field->ID  ) )
         endif
      else  
         hHash_DBF[ "REC" + "_" + ALLTRIM( STR( nRecords ) ) +"_ID" ] = ALLTRIM( field->ID )
      endif
 

but if I input a special character in "Codifica OEM" mode it is not showing correctly on my site...

Image
Image
http://winhotel.space/lp/bergland_sillian/landingpage3.prg?sprache=it

would it be better to work with "codifica ANSI" in general?

thank you a lot and kind regards
ruth

Re: Working with dbf

PostPosted: Tue Jul 27, 2021 8:18 am
by Enrico Maria Giordano
OEM is for the older MS-DOS text.

EMG

Re: Working with dbf

PostPosted: Tue Jul 27, 2021 12:26 pm
by Carles
Ruth,

Your dbf will be encoded in ansi and not in utf8. I recommend that you code on your page if you use dbf as follows

<meta charset = "ISO-8859-1">

If you have the data in the dbf in utf8, you can use the encoding of your page with utf8

<meta charset = "utf-8">

You should be aware of 3 situations if you use dbfs with harbour. As you have your encoded table. As you have encoded your code. and as you encode your web page

Re: Working with dbf

PostPosted: Thu Jul 29, 2021 7:45 am
by Ruth
thank you two very much. this did the trick...now everything is showing fine when I put it manually on the dbfs. now we are building a backend for the user and i will post again :-) kind regards to all of you and have a nice day
ruth