Page 1 of 1
Can't build unicode ODAC 7.10 from source
Posted: Sat 23 Apr 2011 17:32
by Dmlvc
Hello!
We have got official source distribution of ODAC 7.10.0.5. When we try to build it for Delphi 2010 with unicode support, we got an error:
\ODAC_7_10\Source\OraClasses.pas(1650) Fatal: F1026 File not found: 'OraNetW.dcu'
We've used Source\Delphi14\Make.bat and for unicode build we've uncommented next line in Dac.inc
Code: Select all
// Uncomment to make Unicode build
{$DEFINE UNICODE_BUILD}
What have we done wrong?
Thank you!
Posted: Tue 26 Apr 2011 09:56
by AlexP
Hello,
This option is required for unicode support in Delphi 2007 only. Starting from Delphi 2009, unicode is supported by default.
Posted: Tue 26 Apr 2011 10:49
by Dmlvc
Hi!
Hmmmm... It's strange. We use server encoding AL32UTF8. When we use standard ODAC packages from distribution - everything works OK. When we build from source (make.bat) without UNICODE_BUILD - data encoding is wrong (we can see UTF8 byte-by-byte, there is no conversion UTF8 --> Unicode).
There is a line in Ora.pas, class TOraSessionOptions:
Code: Select all
property UseUnicode: boolean read FUseUnicode write SetUseUnicode
default {$IFNDEF UNICODE_BUILD}False{$ELSE}True{$ENDIF};
This may be the case of my error. I should check...
Posted: Tue 26 Apr 2011 13:09
by Dmlvc
Hello!
We have tried again and set explicitly UseUnicode=True. Application works correct now.
Thank you!
Posted: Tue 26 Apr 2011 13:54
by AlexP
Hello,
Glad to see that the problem was solved. If you have any other questions, feel free to contact us.
Posted: Tue 26 Apr 2011 15:01
by Dmlvc
Sorry, but it isn't the end of the story
Data is ok, but error messages are not! We use RUSSIAN_CIS.AL32UTF8 encoding that means russian error messages encoded as UTF8.
An we've got them indeed as UTF8 in spite of UseUnicode option. We expect messages to be Unicode (UTF16) as well as data.
What could go wrong now?
Posted: Tue 26 Apr 2011 15:26
by Dmlvc
Hmm, I've found solution:
Code: Select all
initialization
OraCall.OCIUnicode := True;
It seems to me that you use wrong conditional define for some unicode-aware features. At least here:
Code: Select all
OraCall.pas
{$IFDEF UNICODE_BUILD}
OCIUnicode := True;
{$ELSE}
OCIUnicode := False;
{$ENDIF}
Ora.pas
property UseUnicode: boolean read FUseUnicode write SetUseUnicode
default {$IFNDEF UNICODE_BUILD}False{$ELSE}True{$ENDIF};
In both cases here should be another condition -
IS_UNICODE.
Am I wrong or right?
If I'm right there is another question: why your official build works fine?
Thank You!
Posted: Wed 27 Apr 2011 08:26
by AlexP
Hello,
All ODAC versions (Professional, Source) are built using the same source code and with the same options. So behaviour should be identical. Check that you are using the latest version of the source files and didn't make changes into it.
The IS_UNICODE directive indicates that the version of your IDE supports unicode, and unicode variables should be used.
The UNICODE_BUILD directive is used for unicode support in Delphi 2007 only.
The UseUnicode property and the OCIUnicode global variable should be true by default in Delpphi 2007 only.
To get the correct error messages, the Database and Client encoding should be identical, if it's not, you should set the OCIUnicode global variable to true.
Posted: Wed 27 Apr 2011 13:30
by Dmlvc
Thanks!
Certainly server and client encodings are identical: RUSSIAN_CIS.AL32UTF8. And of course we use latest sources without modifications.
We've just migrated from Delphi 2007 with utf8vcl to Delphi 2010. UTF8 encoding was "native" for 2007 version, UseUnicode and OCIUnicode was True by default.
After migration everything changed. Now "native" encoding for Delphi is AL16UTF16, but we still use AL32UTF8. UseUnicode and OCIUnicode are False now by default, so ODAC never try to convert UTF8 --> UTF16.
That's it.
Posted: Thu 05 May 2011 09:13
by bork
Hello
If you want to use AL32UTF8 charset in your application, you can:
Code: Select all
OraSession1.Options.Charset := 'AL32UTF8';
OraSession1.Options.CharLength := 0; // auto detect
OraSession1.Connect;
OraSession1.ExecSQL('delete from btest0 where id = 20', []);
OraQuery1.SQL.Text := 'select * from btest0';
OraQuery1.Open;
OraQuery1.Append;
OraQuery1.FieldByName('id').AsInteger := 20;
OraQuery1.FieldByName('name').AsString := UTF8Encode('русский');
OraQuery1.Post;
OraQuery1.Close;
OraQuery1.Open;
OraQuery1.Locate('id', 20, []);
ShowMessage(UTF8Decode(OraQuery1.FieldByName('name').AsString)); // show "русский"
But we recommend to use native Delphi Unicode charset - AL16UTF16.