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
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.
Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit
Originally Posted by jmcilhinney
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.
Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit
Originally Posted by Black_Storm
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.
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.
Last edited by dilettante; Mar 7th, 2021 at 02:47 PM.
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.
Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit
Originally Posted by dilettante
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 ?
Re: how fix show json value in textbox or msgbox(my project attached)
Originally Posted by Black_Storm
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).
Re: how fix show json value in textbox or msgbox(my project attached)
Originally Posted by dilettante
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!)
Re: how fix show json value in textbox or msgbox(my project attached)
Originally Posted by dilettante
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.
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 :