-
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
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 :
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
---------------------------------------------------
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?
-
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
Quote:
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
-
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?
-
Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit
Quote:
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.
-
3 Attachment(s)
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 :
Attachment 180440
when i click on command button it is show wrong value in msgbox or textbox like as
Attachment 180441
but correct value is :
---------------------------------------------------------------
any body here can fix my project or solve show numbers?
-
Re: how fix show json value in textbox or msgbox(my project attached)
Quote:
Originally Posted by
Black_Storm
. . .
but correct value is :
Ouch! It's all greek to me :-))
cheers,
</wqw>
-
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
-
Re: how fix show json value in textbox or msgbox(my project attached)
Quote:
Originally Posted by
wqweto
Ouch! It's all greek to me :-))
cheers,
</wqw>
It’s not Greek, it’s Persian :rolleyes:
But like suggested before, you need Unicode controls.
For a Unicode MsgBox replacement:
https://www.vbforums.com/showthread....=1#post3343650
-
1 Attachment(s)
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.
-
Re: how fix show json value in textbox or msgbox(my project attached)
Quote:
Originally Posted by
jpbro
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
-
Re: how fix show json value in textbox or msgbox(my project attached)
Quote:
Originally Posted by
Arnoutdv
i used text box because i need link text box to adodc too and work with adodc,but can u fix show that numbers?
-
Re: how fix show json value in textbox or msgbox(my project attached)
Quote:
Originally Posted by
wqweto
Ouch! It's all greek to me :-))
cheers,
</wqw>
ouch!!! can you fix this porblem?
-
Re: how fix show json value in textbox or msgbox(my project attached)
No, we cannot fix anything. You will have to fix it.
-
Re: how fix show json value in textbox or msgbox(my project attached)
Quote:
Originally Posted by
Eduardo-
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.
-
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?
-
Re: am looking for convert ansi to windows-1256 or utf-8 to wndows-1256 without digit
Quote:
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)
You could use InkEdit controls instead with .InkMode = IEM_Disabled as one solution. They are fully Unicode enabled.
-
Re: how fix show json value in textbox or msgbox(my project attached)
Quote:
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)
I've never tried to untangle the spaghetti of using those controls or even looked at them. Do they support data binding as requested?
-
Re: how fix show json value in textbox or msgbox(my project attached)
Quote:
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)
Quote:
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: 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.
-
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?