Last post Sep 06, 2017 07:10 AM by PatriceSc
Aug 17, 2017 09:29 AMfirstname.lastname@example.org|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.
Aug 17, 2017 09:33 AMemail@example.com|LINK
i tried this, but not given expected result
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)
Aug 30, 2017 06:09 PM|PatriceSc|LINK
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.
Sep 06, 2017 04:24 AMfirstname.lastname@example.org|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.........
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)
Public Function Utf8_Windows_1256(read As String) As String
binary = utf8.GetBytes(read)
Thanks for ur cooperation..
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.