Results 1 to 24 of 24

Thread: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit prb

  1. #1

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit prb

    hi,i have a json utf-8 file ,content is like as :
    HTML Code:
    "header":{
                "date":"۳ روز پیش",
                "subtitle":"۳ روز پیش در مشهد، صیاد شیرازی | اجاره آپارتمان",
                "title":"اوائل صیاد 90 متر",
                "thumbnail":"https://s100.divarcdn.com/static/thumbnails/1614768313/AY_ET-xA.jpg",
                "place":"صیاد شیرازی",
                "business_logo":null
            }
    so when i used json parser like as JsonBag and i wanted show result in a textbox so i used like as this :
    Code:
    text1=headerjson.Item("date")
    or 
    MsgBox headerjson.Item("date")
    but result is like as

    HTML Code:
    ? روز پيش
    so ? is same digit 3 but missing or converted to ?

    i did try with chilkat like as

    Code:
    Dim ss As New ChilkatStringBuilder
    ss.Append (headerjson.Item("date"))
    success = ss.Decode("ansi", "Windows-1256")
    MsgBox ss.GetAsString
    and this time result was been :

    Code:
    3 روز پش
    in this reult fixed number 3 and i found problem is about convert ansi to windows-1256 but in this chilkat example happened another problem about charachter ی because it should be
    HTML Code:
    3 روز پیش
    ---------------------------------------------------
    i want just find a sample code without use chilkat about convert ansi to windows-1256 like as chilkat formula.

    any body can help me about these 2 problems?
    1- how can do that like as chilkat converting ansi to windows-1256

    2-how can fix that ی in example chilkat?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,274

    Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit

    Someone with 300 posts should know that the CodeBank forums are not for asking questions. I have asked the mods to move this thread to the appropriate location.

  3. #3

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit

    Quote Originally Posted by jmcilhinney View Post
    Someone with 300 posts should know that the CodeBank forums are not for asking questions. I have asked the mods to move this thread to the appropriate location.

    i searched more than 2 days but not code found to fix my problem,my question is not about convert file to another file format,my question is about convert string and i did try for more than 20 sources samples but all not worked.
    alls can not fix that ? charachter or (numbers) and ...

    so i am here for find solution
    Last edited by Black_Storm; Mar 6th, 2021 at 11:36 PM.

  4. #4

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit

    any sample to can fix that ? numbers or fix ی charachter string?

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,274

    Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit

    Quote Originally Posted by Black_Storm View Post
    i searched more than 2 days but not code found to fix my problem,my question is not about convert file to another file format,my question is about convert string and i did try for more than 20 sources samples but all not worked.
    alls can not fix that ? charachter or (numbers) and ...

    so i am here for find solution
    None of that is relevant to the fact that you posted in the wrong forum. In fact, it only reinforces the fact that you posted in the wrong forum. CodeBank forums are specifically for sharing working code with others. If you are asking others to help you solve a problem then you don't post in a CodeBank forum. Why you want help or how long you've been looking makes no difference. You don't ask questions in the CodeBank... period. If you want help with VB6 then you post in the VB6 forum. Don't do that now though, because I have already reported this thread to the mods to be moved there. Don't compound the issue by double-posting as well.

  6. #6

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    how fix show json value in textbox or msgbox(my project attached)

    hi,i attached my project.
    my problem is about show correct value from json utf-8 file in a textbox.
    my json file opened in notepad++ is :
    Name:  2.jpg
Views: 649
Size:  24.9 KB

    when i click on command button it is show wrong value in msgbox or textbox like as
    HTML Code:
    ? روز پیش
    Name:  1.png
Views: 522
Size:  18.9 KB

    but correct value is :
    HTML Code:
    ۳ روز پیش
    ---------------------------------------------------------------
    any body here can fix my project or solve show numbers?
    Attached Files Attached Files

  7. #7
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,094

    Re: how fix show json value in textbox or msgbox(my project attached)

    Quote Originally Posted by Black_Storm View Post
    . . .
    but correct value is :
    HTML Code:
    ۳ روز پیش
    Ouch! It's all greek to me :-))

    cheers,
    </wqw>

  8. #8
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,401

    Re: how fix show json value in textbox or msgbox(my project attached)

    Did you try Krool's Unicode common controls replacement TextBox? It worked for me here:

    Attachment 180443

  9. #9
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,856

    Re: how fix show json value in textbox or msgbox(my project attached)

    Quote Originally Posted by wqweto View Post
    Ouch! It's all greek to me :-))

    cheers,
    </wqw>
    It’s not Greek, it’s Persian

    But like suggested before, you need Unicode controls.
    For a Unicode MsgBox replacement:
    https://www.vbforums.com/showthread....=1#post3343650

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit

    Code:
    Option Explicit
    
    Private Const WIN32_NULL As Long = 0
    
    Private Declare Function MessageBox Lib "user32" Alias "MessageBoxW" ( _
        ByVal hWnd As Long, _
        ByVal lpText As Long, _
        Optional ByVal lpCaption As Long = WIN32_NULL, _
        Optional ByVal uType As VbMsgBoxStyle = vbOKOnly) As VbMsgBoxResult
    
    Private Sub Main()
        Dim JsonBag As JsonBag
    
        ChDir App.Path
        ChDrive App.Path
        With New ADODB.Stream
            .Open
            .Type = adTypeText
            .Charset = "utf-8"
            .LoadFromFile "sample.json"
            Set JsonBag = New JsonBag
            JsonBag.JSON = .ReadText(adReadAll)
            .Close
        End With
        With JsonBag.Item("header")
            MessageBox WIN32_NULL, StrPtr(.Item("date")), StrPtr("date")
            MessageBox WIN32_NULL, StrPtr(.Item("subtitle")), StrPtr("subtitle")
        End With
    End Sub
    No character encoding changes needed. The .JSON property is Unicode (UTF-16LE), just as the String values are.
    Attached Files Attached Files
    Last edited by dilettante; Mar 7th, 2021 at 02:47 PM.

  11. #11

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how fix show json value in textbox or msgbox(my project attached)

    Quote Originally Posted by jpbro View Post
    Did you try Krool's Unicode common controls replacement TextBox? It worked for me here:

    Attachment 180443
    you attachment is not valid,check and send again

  12. #12

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how fix show json value in textbox or msgbox(my project attached)

    Quote Originally Posted by Arnoutdv View Post
    It’s not Greek, it’s Persian

    But like suggested before, you need Unicode controls.
    For a Unicode MsgBox replacement:
    https://www.vbforums.com/showthread....=1#post3343650

    i used text box because i need link text box to adodc too and work with adodc,but can u fix show that numbers?

  13. #13

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how fix show json value in textbox or msgbox(my project attached)

    Quote Originally Posted by wqweto View Post
    Ouch! It's all greek to me :-))

    cheers,
    </wqw>
    ouch!!! can you fix this porblem?

  14. #14
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,987

    Re: how fix show json value in textbox or msgbox(my project attached)

    No, we cannot fix anything. You will have to fix it.

  15. #15

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how fix show json value in textbox or msgbox(my project attached)

    Quote Originally Posted by Eduardo- View Post
    No, we cannot fix anything. You will have to fix it.
    we?!!! ofcourse you are more than 1 people lol.

    i usually did try for fix my problems with ask and compare solutions and other helps.
    so this is way of fix.
    Last edited by Black_Storm; Mar 7th, 2021 at 10:39 PM.

  16. #16

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how fix show json value in textbox or msgbox(my project attached)

    for example i can use chilkat and fix problem (90%) like as this :

    Code:
    Dim ss As New ChilkatStringBuilder
    ss.Append (headerjson.Item("date"))
    success = ss.Decode("ansi", "Windows-1256")
    MsgBox ss.GetAsString
    'or
    text1=ss.GetAsString
    but i dont want fix this problem with external dll

    or i see answer from dilettante in my another thread about this problem like as :

    Code:
    Option Explicit
    
    Private Const WIN32_NULL As Long = 0
    
    Private Declare Function MessageBox Lib "user32" Alias "MessageBoxW" ( _
        ByVal hWnd As Long, _
        ByVal lpText As Long, _
        Optional ByVal lpCaption As Long = WIN32_NULL, _
        Optional ByVal uType As VbMsgBoxStyle = vbOKOnly) As VbMsgBoxResult
    
    Private Sub Main()
        Dim JsonBag As JsonBag
    
        ChDir App.Path
        ChDrive App.Path
        With New ADODB.Stream
            .Open
            .Type = adTypeText
            .Charset = "utf-8"
            .LoadFromFile "sample.json"
            Set JsonBag = New JsonBag
            JsonBag.JSON = .ReadText(adReadAll)
            .Close
        End With
        With JsonBag.Item("header")
            MessageBox WIN32_NULL, StrPtr(.Item("date")), StrPtr("date")
            MessageBox WIN32_NULL, StrPtr(.Item("subtitle")), StrPtr("subtitle")
        End With
    End Sub

    i use be textbox because i need use adodc control in my prokect for link bind data between textbox and fields.so how can i show it in textbox or any textbox unicode support with suppord bind data?
    Last edited by Black_Storm; Mar 7th, 2021 at 10:27 PM.

  17. #17

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit

    Quote Originally Posted by dilettante View Post
    Code:
    Option Explicit
    
    Private Const WIN32_NULL As Long = 0
    
    Private Declare Function MessageBox Lib "user32" Alias "MessageBoxW" ( _
        ByVal hWnd As Long, _
        ByVal lpText As Long, _
        Optional ByVal lpCaption As Long = WIN32_NULL, _
        Optional ByVal uType As VbMsgBoxStyle = vbOKOnly) As VbMsgBoxResult
    
    Private Sub Main()
        Dim JsonBag As JsonBag
    
        ChDir App.Path
        ChDrive App.Path
        With New ADODB.Stream
            .Open
            .Type = adTypeText
            .Charset = "utf-8"
            .LoadFromFile "sample.json"
            Set JsonBag = New JsonBag
            JsonBag.JSON = .ReadText(adReadAll)
            .Close
        End With
        With JsonBag.Item("header")
            MessageBox WIN32_NULL, StrPtr(.Item("date")), StrPtr("date")
            MessageBox WIN32_NULL, StrPtr(.Item("subtitle")), StrPtr("subtitle")
        End With
    End Sub
    No character encoding changes needed. The .JSON property is Unicode (UTF-16LE), just as the String values are.
    thanks for answer but i did try for show in lables unicode support control before send this thread too but i need textbox to can link to adodc too.

    thanks but its important to me to i show it in text box ,because i used adodc and textbox bined to data fields and so i should be save data in database or show it in textbox with adodc control.so any solution for fix ?

  18. #18
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: how fix show json value in textbox or msgbox(my project attached)

    You could use InkEdit controls instead with .InkMode = IEM_Disabled as one solution. They are fully Unicode enabled.

  19. #19
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,401

    Re: how fix show json value in textbox or msgbox(my project attached)

    Quote Originally Posted by Black_Storm View Post
    you attachment is not valid,check and send again
    It was just a screenshot showing the correct output in a TextBox (Krool's). You need to use a TextBox that supports Unicode, and Krool's is a good choice (especially if you don't want to use an external DLL/OCX).

  20. #20
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: how fix show json value in textbox or msgbox(my project attached)

    I've never tried to untangle the spaghetti of using those controls or even looked at them. Do they support data binding as requested?

  21. #21
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,401

    Re: how fix show json value in textbox or msgbox(my project attached)

    Quote Originally Posted by dilettante View Post
    I've never tried to untangle the spaghetti of using those controls or even looked at them. Do they support data binding as requested?
    Je pense que oui, but I've never used it myself so I can't vouch for it. There are DataBindings, DataField, DataFormat, DataMember, and DataSource properties for the TextBoxW control.

    That said, I just saw your InkEdit suggestion, and that would work too (unless it doesn't come bundled with Windows XP - which I'm sure will be the next requirement!)

  22. #22

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how fix show json value in textbox or msgbox(my project attached)

    Quote Originally Posted by dilettante View Post
    You could use InkEdit controls instead with .InkMode = IEM_Disabled as one solution. They are fully Unicode enabled.
    thanks for answer but if i want use inkedit control (inked.dll) in my project so i can use same chilkat dll or another ocx unicode support too ,as i said in #10 i wana try for dont use external dll or ocx unicode support,maybe i can fix my problem with find some usercontrols or sample codes like as encode convertor like as function decode in chilkat.

  23. #23

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: how fix show json value in textbox or msgbox(my project attached)

    important for me is i show that string in text box and use adodc for save to database or show ,navigate ,save and delete records too.

  24. #24

    Thread Starter
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit

    1-i used inkedit for show my string.
    2-i linked adodc to inkedit and binded to a field and when i checked data
    3-data saved in filed is like as rtf because i used inkedit - for example saved like as this :
    HTML Code:
    {\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1065{\fonttbl{\f0\fnil\fcharset178{\*\fname Tahoma;}Tahoma (barnameha.net);}}
    {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\ltrpar\qr\f0\rtlch\fs18\'c2\'81\'c7\'d1\'ca\'e3\'c7\'e4 \u1785?\u1782? \'e3\'ca\'d1 \'cf\'d1 \'d4\'d1\u1740?\'da\'ca\u1740?\par
    }
    it is same
    HTML Code:
    {"date":"۳ روز پیش"}
    3-now my porblem is about how show this data in datagird.
    for example i find a grid support unicode like as :
    VBFlexGrid Control (Replacement of the MSFlexGrid control)

    but how can show in this grid ?

    or any sample to show in another grids too?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width