473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Wrong string length from unicode database in Borland's app

Hi,

I have windows app written in Borland C++ Builder 5.0. Using ODBC
driver windows app connects to database on linux server. Database is
created with UNICODE encoding.

When pg-server is version 7.1.3 windows app works fine, but when
pg-server is version 7.4.6 or 8.0beta4 under certain conditions the
app receives strings with wrong lengths. For example: the database
contains table "issue" with the following structure:

Column | Type | Modifiers
-----------+--------------------------+---------------
id | integer | not null ...
mag_id | integer |
year | character(36) |
volume | character(78) |
number | character(300) |
user_name | character(20) | default getpgusername()
mod_date | timestamp with time zone | default now()

Only the column "volume" can contain unicode symbols.

When the the windows application executes the following query:

select year, trim(number) from issue where mag_id = 25403;

all works fine. But by executing the query

select volume, trim(number) from issue where mag_id = 25403;

the datagrid component (that displays query's results) contains in
second column values with length of 32769. Those big values are only
in rows where appropriate "volume" field contains unicode symbols.
Actually all values in column "number" are 5-7 symbols long.

By executing the query

select year, number from issue where mag_id = 25403;

all works fine.

I have checked several versions of ODBC-driver: 07.03.0200,
07.05.0001, 08.00.0002 - the effects are the same: all works fine with
postgres-server 7.1.3 and works bad with 7.4.6 or 8.0beta4

Changing of driver settings (as described on
http://gborg.postgresql.org/project/...bc/faq/faq.php in "Borland
Apps" section) does not help too. My setup is:

Parse Statements - checked
Unknown Sizes - Longest
Text as LongVarChar - checked
Unknowns as LongVarChar - unchecked

Without those settings the windows app works even worse.

Please help me to solve this problem. May be I'm doing something
wrong? May be my windows is set up incorrectly? (I'm using Win2K SP4)
Or is this a ODBC-driver's bug? Or server's? Or may be it's a Borlands
BDE error?

Has somebody used windows app written in borland to connect to
unicode table under postgresql > 7.1.3 ?
Best regards,
Alex
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #1
2 3704
Alex Guryanow <ga*@nlr.ru> writes:
When pg-server is version 7.1.3 windows app works fine, but when
pg-server is version 7.4.6 or 8.0beta4 under certain conditions the
app receives strings with wrong lengths.
Are both servers set up with the same database encoding? (Is the 7.1
server even compiled to support non-ASCII encodings?)
But by executing the query
select volume, trim(number) from issue where mag_id = 25403;
the datagrid component (that displays query's results) contains in
second column values with length of 32769.


If you try the same query in plain psql, what do you get? What is in
the wrong-length value, exactly?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #2
TL> Alex Guryanow <ga*@nlr.ru> writes:
When pg-server is version 7.1.3 windows app works fine, but when
pg-server is version 7.4.6 or 8.0beta4 under certain conditions the
app receives strings with wrong lengths.
TL> Are both servers set up with the same database encoding?

I think the answer is yes. For both servers the command "initdb" was
executed only with parameter DATADIR. At the same time the locale is
set up to "ru_RU.cp1251".

But by creating the database I specify parameter "-E UNICODE" and
"psql -l" shows that the database is in UNICODE encoding. One
time I have forgotten to specify '-E UNICODE' by executing createdb
and windows app worked fine with 7.4.6
TL> (Is the 7.1
TL> server even compiled to support non-ASCII encodings?)

Here is the fragment of config.status from 7.1.3 source directory

../configure --prefix=/db/pgsql-713 --enable-locale --enable-multibyte --with-perl

But by executing the query
select volume, trim(number) from issue where mag_id = 25403;
the datagrid component (that displays query's results) contains in
second column values with length of 32769.


TL> If you try the same query in plain psql, what do you get?

I get all ok. For example, the query

select volume, length( trim( number ) ) from issue where mag_id = 25403;

shows in second column values from 5 to 7

TL> What is in
TL> the wrong-length value, exactly?

'N 1-2'

The appropriate "volume" column contains 'Evf. 120' where 'E' is 'E
with ascent' (I don't know how to write them in this letter). pg_dump
writes the following sequence of bytes (in hex-format) for this value:

C3 89 76 66 2E 20 31 32 30

and 'N 1-2' is

4E 20 31 2D 32
Best regards,
Alex
TL> regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Jeannie | last post by:
Hello group! I'm in Europe, traveling with my laptop, and I don't any compilers other than Borland C++ 5.5. available. I also don't have any manuals or help files available. Sadly, more...
5
by: Sia Jai Sung | last post by:
Hi, I have a class that I modify from a sample program, like below ========================================== Imports System Imports System.Web.UI Imports System.Security.Cryptography ...
4
by: Scott Lemen | last post by:
Hi, Some Win APIs expect a structure with a fixed length string. How is it defined in VB .Net 2003? When I try to use the FixedLengthString class I get an "Array bounds cannot appear in type...
7
by: pattreeya | last post by:
Hello, how can I get the number of byte of the string in python? with "len(string)", it doesn't work to get the size of the string in bytes if I have the unicode string but just the length. (it...
1
by: willie | last post by:
>willie wrote: wrote:
5
by: jeremyje | last post by:
I'm writing some code that will convert a regular string to a byte for compression and then beable to convert that compressed string back into original form. Conceptually I have.... For...
20
by: Xcriber51 | last post by:
Hi -- I'm not entirely familiar with the norms and standard libraries of JavaScript so if the answer to this is yesterday's news, please ignore. I'm trying to write a simple text formatting...
8
by: adamisko | last post by:
Hello, what is wrong with this code, I want to divide string to pieces 4 chars length. string tekst = "divide string to 4 chars pieces"; Regex regex = new Regex("(.{1,4})"); string substrings =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.