Issue with russian characters on Mobile (resolved)

Issue with russian characters on Mobile (resolved)

Postby dnomaid » Fri 26 Oct 2012 12:19

Hello all,
I use dotConnect for Oracle Mobile v. 7.2.104.2 trial, Visual Studio 2008, Pocket PC 2003 SE emulator, .NET Compact Framework 3.5

When I read data from Oracle, russian letters appear as upside down question marks ("¿¿¿¿").
Then I set Unicode = true, russian letters begin to show as 'Ð' and other wrong letters:
Code: Select all
//                 017.000.00439,СкÐ,4,
//                 017.000.00502,Sklad,5,
//                 017.000.00505,SkлÐ,2,

Here is my sample project, which behaves the same way on Pocket PC 2003 SE emulator and on the real device (Motorola WT4090 w/WinCE 5.0).
https://docs.google.com/open?id=0B3wtMQ_73yxiZnhnZkRBYXNRQ00
I also included a SQL script that creates a sample database.

Here are the sample methods:
Code: Select all
        private void connectOracle()
        {
            OracleConnectionStringBuilder oraCSB = new OracleConnectionStringBuilder();
            oraCSB.Server = "172.19.1.70";
            oraCSB.Sid = "DEV";
            oraCSB.Port = 1541;
            oraCSB.UserId = "ADMIN";
            oraCSB.Password = "ADMIN";
            oraCSB.MaxPoolSize = 150;
            oraCSB.ConnectionTimeout = 30;
            oraCSB.Unicode = true;
            OracleConnection myConnection = new OracleConnection(oraCSB.ConnectionString);

            myConnection.Open();
            MessageBox.Show(myConnection.ServerVersion);
            testOracle1(myConnection);
            myConnection.Close();
        }

        private void testOracle1(OracleConnection connection)
        {
            OracleCommand command = connection.CreateCommand();
            command.CommandText = "select * from XX_DEVART_TEST";

            using (OracleDataReader reader = command.ExecuteReader())
            {
                UnicodeEncoding unicode = new UnicodeEncoding();
                // printing the column names
                for (int i = 0; i < reader.FieldCount; i++)
                    Console.Write(reader.GetName(i).ToString() + "\t");
                Console.Write(Environment.NewLine);
                // Always call Read before accesing data
                string res = "";
                while (reader.Read())
                {
                    // printing the table content
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        object val = reader.GetValue(i);
                        Console.Write(val.ToString() + "\t");
                        res += val.ToString() + ",";

//                         long length = reader.GetBytes(i, 0, null, 0, 0);
//                         byte[] rawBytes = new byte[length];
//                         reader.GetBytes(i, 0, rawBytes, 0, (int)length);

//                        byte[] bytes = unicode.GetBytes(val.ToString());
                    }
                    Console.Write(Environment.NewLine);
                    res += Environment.NewLine;
                }
                // res is:
//                 017.000.00439,СкÐ,4,
//                 017.000.00502,Sklad,5,
//                 017.000.00505,SkлÐ,2,

                MessageBox.Show(res);

                // But should be:
//                 017.000.00439,Склад,4,
//                 017.000.00502,Sklad,5,
//                 017.000.00505,Skлад,2,
            }
        }


I'm new to dotConnect, so please point out what I'm doing wrong. Or is it a bug?
Thanks in advance.
Last edited by dnomaid on Fri 14 Dec 2012 14:40, edited 3 times in total.
dnomaid
 
Posts: 3
Joined: Fri 26 Oct 2012 11:14

Re: Issue with russian characters on Mobile

Postby dnomaid » Mon 29 Oct 2012 14:19

I've got some good news.
Code: Select all
select CONVERT(SUBINVENTORY_CODE, 'AL16UTF16LE', 'CL8ISO8859P5') as SUBINVENTORY_CODE from XX_DEVART_TEST

My colleague told me about SQL encoding conversions, so I tried all of them and finally found out the correct one. You'll have to do it for each database column that can have non-ascii characters.
Then:
Code: Select all
oraCsb.Unicode = false; // IMPORTANT!
// ...
// Reading a field:
long length = reader.GetBytes(i, 0, null, 0, 0);
byte[] rawBytes = new byte[length];
reader.GetBytes(i, 0, rawBytes, 0, (int)length);
string val = Encoding.Unicode.GetString(rawBytes, 0, (int)length);

So, now it works, but still one question remains.

Is it possible to initialize OracleConnection with custom encoding conversion? (i.e. from CL8ISO8859P5 to AL16UTF16LE). The Unicode setting is, obviously, not sufficient in this case.
dnomaid
 
Posts: 3
Joined: Fri 26 Oct 2012 11:14

Re: Issue with russian characters on Mobile (partially resolved)

Postby Pinturiccio » Mon 29 Oct 2012 16:14

We have reproduced the issue. We will investigate it and notify you about the results as soon as possible.

As a temporary workaround, you can change the SUBINVENTORY_CODE column type from CHAR to NCHAR or NVARCHAR2.
This can be done by changing your database script. In your script, the CHAR type is assigned to your CONCATENATED_SEGMENTS and SUBINVENTORY_CODE columns. To make it NVARCHAR2, you should use the to_nchar function in the creation script. Then your script will be as follows:
Code: Select all
create table XX_DEVART_TEST AS
select '017.000.00439' as CONCATENATED_SEGMENTS,
TO_NCHAR('Склад') as SUBINVENTORY_CODE,
4 as TRANSACTION_QUANTITY
from dual
union all
select '017.000.00502' as CONCATENATED_SEGMENTS,
TO_NCHAR('Sklad') as SUBINVENTORY_CODE,
5 as TRANSACTION_QUANTITY
from dual
union all
select '017.000.00505' as CONCATENATED_SEGMENTS,
TO_NCHAR('Skлад') as SUBINVENTORY_CODE,
2 as TRANSACTION_QUANTITY
from dual;
Pinturiccio
Devart Team
 
Posts: 1955
Joined: Wed 02 Nov 2011 09:44

Re: Issue with russian characters on Mobile (partially resolved)

Postby Pinturiccio » Tue 27 Nov 2012 14:20

We have reproduced the issue in dotConnect for Oracle Mobile 7.2.104, but the issue is not reproduced in the latest version 7.2.122. So you can download it at http://www.devart.com/dotconnect/oracle/download.html (the trial version) or from Registered Users' Area (for users with valid subscription only).

You can also change Regional Settings to Russian (for dotConnect for Oracle Mobile 7.2.104, version 7.2.122 does not require this). This can be done in the following window (for Pocket PC 2003 Second Edition): Start->Settings->System->Regional Settings. Then your application should show correct Russian characters when connection string parameter 'Unicode=false' is used.
Pinturiccio
Devart Team
 
Posts: 1955
Joined: Wed 02 Nov 2011 09:44

Re: Issue with russian characters on Mobile (partially resolved)

Postby dnomaid » Fri 14 Dec 2012 14:39

Thank you very much! Now it works with Unicode = true, in both ways, upload and download.

However, when when I set Unicode = false, it does not work. The locale is Russian, OS interface language is English (Windows CE 5.0, Motorola WT4090). That doesn't bother me, just for your information.
dnomaid
 
Posts: 3
Joined: Fri 26 Oct 2012 11:14


Return to dotConnect for Oracle