Need the encoding function for saving Arabic text , taken as user input to save into oracle database and as well to retrieve data to show the same on the form as well.
Private Function getabctest(ByVal str As String) As String
Dim iso As Encoding = Encoding.GetEncoding("ISO-8859-1")
Dim utf8 As Encoding = Encoding.UTF8
Dim utfBytes() As Byte = utf8.GetBytes(str)
Dim isoBytes() As Byte = Encoding.Convert(utf8, iso, utfBytes)
Dim msg As String = iso.GetString(isoBytes)
Return msg
Seems you are trying to turn Unicode characters into ISO 8859 which will never work. I'm not using Oracle but AFAIK as for SQL Server and for most if not all DBMS you should be able to handle that transparently.
AFAIK .NET uses UTF-16 and handles converting from what is used for the incoming http request and what is used for the browser response automatically.
Similarly the DBMS driver should take care of converting the .NET string to the target column format. Of course you have to ensure that the target column format is Unicode else you'll have a ? where character is outside of allowed characters for this column.
Is this the behavior you see? What is the target column type (needs NVARCHAR, not VARCHAR).
I'm not using Oracle but I'm pretty sure that if you need to do the conversion yourself there is likely something wrong in the current approach.
Thanks for ur suggestion.. i tried this and is working for oracle....For sqlserver, no need to convert, it is saving directly as user input language.. issue was with oracle..so i had used this approach.........
It's been a long time but I'm fairly sure you can configure Oracle to transform characters back and forth as you want so that you don't have to do that explicitly each time you access the db which would be a nightmare.
None
0 Points
12 Posts
Encoding Method for saving unicode data(Arabic. hebrew, greek .. ) into oracle database
Aug 17, 2017 09:29 AM|nadkazmi@gmail.com|LINK
Need the encoding function for saving Arabic text , taken as user input to save into oracle database and as well to retrieve data to show the same on the form as well.
None
0 Points
12 Posts
Re: Encoding Method for saving unicode data(Arabic. hebrew, greek .. ) into oracle database
Aug 17, 2017 09:33 AM|nadkazmi@gmail.com|LINK
i tried this, but not given expected result
Imports System.Text
.....
Private Function getabctest(ByVal str As String) As String
Dim iso As Encoding = Encoding.GetEncoding("ISO-8859-1")
Dim utf8 As Encoding = Encoding.UTF8
Dim utfBytes() As Byte = utf8.GetBytes(str)
Dim isoBytes() As Byte = Encoding.Convert(utf8, iso, utfBytes)
Dim msg As String = iso.GetString(isoBytes)
Return msg
End Function
All-Star
45870 Points
16703 Posts
Re: Encoding Method for saving unicode data(Arabic. hebrew, greek .. ) into oracle database
Aug 30, 2017 06:09 PM|PatriceSc|LINK
Hi,
Seems you are trying to turn Unicode characters into ISO 8859 which will never work. I'm not using Oracle but AFAIK as for SQL Server and for most if not all DBMS you should be able to handle that transparently.
AFAIK .NET uses UTF-16 and handles converting from what is used for the incoming http request and what is used for the browser response automatically.
Similarly the DBMS driver should take care of converting the .NET string to the target column format. Of course you have to ensure that the target column format is Unicode else you'll have a ? where character is outside of allowed characters for this column.
Is this the behavior you see? What is the target column type (needs NVARCHAR, not VARCHAR).
I'm not using Oracle but I'm pretty sure that if you need to do the conversion yourself there is likely something wrong in the current approach.
None
0 Points
12 Posts
Re: Encoding Method for saving unicode data(Arabic. hebrew, greek .. ) into oracle database
Sep 06, 2017 04:24 AM|nadkazmi@gmail.com|LINK
Thanks for ur suggestion.. i tried this and is working for oracle....For sqlserver, no need to convert, it is saving directly as user input language.. issue was with oracle..so i had used this approach.........
While Saving..
calling user defined function with user input ..
strsql= strsql & "'" & SetStringToWindows1256(TXTNAME_NLS.Text.ToString()) & "',"
and while populating data on the form..
TXTNAME_NLS.Text = Utf8_Windows_1256(lvRS("TMI_MATL_DESC_NLS"))
functions are ...
Public Function SetStringToWindows1256(read As String) As String
Dim utf8 As System.Text.Encoding
Dim windows_1256 As System.Text.Encoding
Dim binary As Byte()
utf8 = System.Text.Encoding.GetEncoding("iso8859-1")
windows_1256 = System.Text.Encoding.GetEncoding("windows-1256")
binary = windows_1256.GetBytes(read)
Return utf8.GetString(binary)
End Function
and
Public Function Utf8_Windows_1256(read As String) As String
Dim utf8 As System.Text.Encoding
Dim windows_1256 As System.Text.Encoding
Dim binary As Byte()
utf8 = System.Text.Encoding.GetEncoding("iso8859-1")
windows_1256 = System.Text.Encoding.GetEncoding("windows-1256")
binary = utf8.GetBytes(read)
Return windows_1256.GetString(binary)
End Function
Thanks for ur cooperation..
All-Star
45870 Points
16703 Posts
Re: Encoding Method for saving unicode data(Arabic. hebrew, greek .. ) into oracle database
Sep 06, 2017 07:10 AM|PatriceSc|LINK
It's been a long time but I'm fairly sure you can configure Oracle to transform characters back and forth as you want so that you don't have to do that explicitly each time you access the db which would be a nightmare.
See maybe http://www.oracle.com/technetwork/products/globalization/nls-lang-099431.html or check rather a specialized Oracle forum.
For now it seems you are trying to convert Arabic to a non Unicode page code which will never work.