Need Guidance-Help --- UTF8

36 views
Skip to first unread message

hema...@gmail.com

unread,
Jul 16, 2026, 7:25:48 AM (10 days ago) Jul 16
to [oohg]
Hello All Guru

I am developing software where I want to use "Hindi" (UTF8) and using RICHEDITBOX control.
For entry/saving and display in grid it shows correct values. At the time of editing when values flow into the RICHEDITBOX control it display all "Garbage" Charecter.

Please guide me how to get the correct value in RICHEDITBOX instead of garbage.

Any guidance is much appreciated.


Regards
Hemant


Below is my code

This is define in my main function
    REQUEST HB_CODEPAGE_UTF8
     HB_CDPSELECT("UTF8")
// HB_SETTERMCP("UTF8")
     SET CODEPAGE TO UTF8


prdgrp.prg
 
#include "oohg.ch"
#include "xprtoohg.ch"
#include "hbextcdp.ch"

FUNCTION prdgrp_Master()
    LOCAL aCols := { {"Product Group Name", 300, "pgname"} }
   
LOCAL cHindiText := "नमस्ते हिन्दी"

// MsgInfo( cHindiText+"  Lenght UTF-8 "+ ValToPrg(hb_utf8Len(cHindiText))+"  Normal "+ValToPrg(len(cHindiText)), "Checking Core UTF-8 Text Support" )


    IF IsWindowActive(frm_xspgmast)
        DoMethod("frm_xspgmast", "SetFocus")
        RETURN NIL
    ENDIF

    DEFINE WINDOW frm_xspgmast AT 100,500 WIDTH 450 HEIGHT 500 TITLE "Product Group Master" CHILD NOMAXIMIZE BACKCOLOR XPRT_BACKCLR

    ON KEY ESCAPE ACTION (frm_xspgmast.Release)
       
        @ 10,10 LABEL lblS VALUE "Search:" WIDTH 60
        @ 10,80 TEXTBOX txtSearch WIDTH 250 ON CHANGE RefreshGrid("xspgmast", aCols, "frm_xspgmast", This.Value)

        @ 45,10 GRID grdData ;
            WIDTH 410 HEIGHT 350 ;
FONT 'Arial';
            HEADERS {"Group Name", "ID"} ;  // Added ID Header
            WIDTHS {300, 0} ;              // Width 0 hides it
            ON DBLCLICK Area_Form( GetGridId("frm_xspgmast", "grdData") )

        @ 410,10 BUTTON btnAdd CAPTION "Add" ACTION Area_Form(0) WIDTH 80
       
        @ 410,100 BUTTON btnEdit CAPTION "Edit" ;
            ACTION Area_Form( GetGridId("frm_xspgmast", "grdData") ) WIDTH 80

        @ 410,190 BUTTON btnDel CAPTION "Delete" ;
            ACTION Area_Delete() WIDTH 80


        frm_xspgmast.btnAdd.Enabled    := AppHasPermission( "MASTER_ADD" )
    frm_xspgmast.btnEdit.Enabled   := AppHasPermission( "MASTER_EDIT" )
        frm_xspgmast.btnDel.Enabled    := AppHasPermission( "MASTER_DELETE" )

    END WINDOW
   
    RefreshGrid("xspgmast", aCols, "frm_xspgmast")
    Activate Window frm_xspgmast
RETURN NIL

STATIC FUNCTION Area_Delete()
    LOCAL nId := GetGridId("frm_xspgmast", "grdData")
    LOCAL aCols := { {"Group Name", 300, "pgname"} }
   
    IF nId > 0 .AND. MsgYesNo("Are you sure you want to delete?")
        IF DB_Delete("xspgmast", "id=" + hb_ntos(nId))
            RefreshGrid("xspgmast", aCols, "frm_xspgmast")
        ENDIF
    ENDIF
RETURN NIL

STATIC FUNCTION Area_Form(nId)

    LOCAL cName := ""
    LOCAL cTitle := IF(nId == 0, "Add Product Group", "Edit Product Group")
    LOCAL hWndTxt := 0
local txtName := ""

    IF nId > 0
    cEditName := DB_GetOne("SELECT pgname FROM xspgmast WHERE id=" + hb_ntos(nId))
        cName := alltrim(cEditName)           // HB_StrToUTF8( hb_Translate( alltrim(cEditName), "EN", "UTF8" ) )      //DB_GetOne("SELECT pgname FROM xspgmast WHERE id=" + hb_ntos(nId))
msginfo(cEditName+" - "+cName)
    ENDIF

    DEFINE WINDOW frmEdit AT 300,525 WIDTH 400 HEIGHT 200 TITLE cTitle MODAL BACKCOLOR XPRT_BACKCLR  

        @ 30,20 LABEL lbl1 VALUE "Group Name: " WIDTH 100
 
        // Swap out the keyword TEXTBOX for RICHEDITBOX
        @ 30, 100 RICHEDITBOX txtName ;
            VALUE "" ;
            WIDTH 200 ;
            HEIGHT 24 ; // Give it a single-line height profile
            FONT "Arial" ;
            SIZE 11 ;
            MAXLENGTH 100;
            NOVSCROLL NOHSCROLL
 
       
        // The save button calls GetControlHandle() to fetch the live text data via our custom C block
        @ 100,130 BUTTON btnSave CAPTION "Save" ;
   ACTION Group_Save(nId, GetProperty("frmEdit","txtName","Value")) WIDTH 80
           
        @ 100,220 BUTTON btnCan CAPTION "Cancel" ACTION ThisWindow.Release WIDTH 80
    END WINDOW

IF nId > 0
        SetProperty( "frmEdit", "txtName", "Value", cName )
    ENDIF
   
    ACTIVATE WINDOW frmEdit
RETURN NIL


STATIC FUNCTION Group_Save(nId, cName)
    LOCAL aCols := { {"Product Group Name", 300, "pgname"} }
   
    cName := AllTrim(cName)
    IF Empty(cName) ; MsgStop("Name required") ; RETURN NIL ; ENDIF

    // Pass the clean cName string straight through
    IF CheckDuplicate("xspgmast", "pgname", cName, nId, "id")
        MsgStop("Product Group Name already exists")
        RETURN NIL
    ENDIF

    // Both commands now pass cName directly without extra encoding wrappers
    IF nId == 0
        DB_Insert("xspgmast", {{"cmpid", g_cmpcode}, {"pgname", cName}})
    ELSE
        DB_Update("xspgmast", {{"pgname", cName}}, "id=" + hb_ntos(nId))
    ENDIF
   
    DoMethod("frmEdit", "Release")
    RefreshGrid("xspgmast", aCols, "frm_xspgmast")
RETURN NIL

José Santos Arias Vega

unread,
Jul 18, 2026, 3:46:51 AM (9 days ago) Jul 18
to oo...@googlegroups.com
Si usas notepad graba como utf-8 podría servir

--
Has recibido este mensaje porque estás suscrito al grupo "[oohg]" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a oohg+uns...@googlegroups.com.
Para ver este debate, visita https://groups.google.com/d/msgid/oohg/253c3702-b4d8-4e52-9824-2a5c34b0f13cn%40googlegroups.com.

hema...@gmail.com

unread,
Jul 19, 2026, 4:17:04 AM (8 days ago) Jul 19
to [oohg]
Hi 

Thanks for your reply.

Looks like I haven't describe the issue correctly.  In data entry using RICHEDITBOX control it accept and shows correct value. It stores correct value (UTF8) in MYSQL Table and after saving it display correctly in GRID where I am fetching the record from table. But when reading back the value from GRID  in MSGINFO() it shows correct values (UTF8) but in RICHEDITBOX control it shows "GARBAGE Charectors" 

Please check the attached file for screen shot. 

FYI TEXTBOX control dosen't accept the UTF8 charector. It always shows  "??????" 

Please guide me. 

Regards
Hemant
UTF8 Issues.pdf

José Santos Arias Vega

unread,
Jul 20, 2026, 6:46:55 PM (6 days ago) Jul 20
to oo...@googlegroups.com
Hola,

Para caracteres especiales yo utilizo lo siguiente

REQUEST HB_CODEPAGE_ESWIN
hb_setcodepage("ESWIN ")

function main()
/// Acá van las variables locales /////////
HB_CDPSELECT('ESWIN')
HB_LANGSELECT('ES')
SET LANGUAGE TO SPANISH

Podría servirte.

Saludos


José Arias Vega

Reply all
Reply to author
Forward
0 new messages