Subject | RE: [Firebird-Java] trailing spaces with UNICODE_FSS |
---|---|
Author | Sezer Yesiltas |
Post date | 2004-02-29T08:12:33Z |
This is not a bug.
When you use unicode_fss you are able to use all possible char sets for
example chinese,japan,arabic etc.
For this purpose every character in unicode_fss is represented with 3 bytes.
Since latin characters take just 1 byte, there is extra 2 bytes as space.
For example since a chinese character would take 3 bytes, there would be no
extra spaces.
Sezer.
_____
From: Dmitry Shohov [mailto:shofa@...]
Sent: Monday, February 23, 2004 5:38 PM
To: Firebird-Java@yahoogroups.com
Subject: [Firebird-Java] trailing spaces with UNICODE_FSS
Hi!
I created database with default character set UNICODE_FSS. When I
try to get values from columns with char type, JayBird returns strings
with trailing spaces (e.g. if there is column with type char(1) and
value 'A' it returns 'A ' with two spaces at the end).
Is this a bug? Or may be I missed something?
I used JayBird 1.5 beta3 and firebird 1.5.0/1.0.3. OS - Win2000.
Thanks,
Dmitry Shohov
Database script:
CREATE DATABASE 'C:\Projects\bugtest\bugtest.gdb'
USER 'SYSDBA' PASSWORD 'masterkey'
DEFAULT CHARACTER SET UNICODE_FSS;
CREATE TABLE TESTTABLE (
TESTVALUE CHAR(1)
);
INSERT INTO TESTTABLE VALUES('A');
COMMIT;
Java test class:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Test {
public static void main(String[] args) {
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection connection =
DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:c:\\Projects\\b
ugtest\\bugtest.gdb?lc_ctype=UNICODE_FSS", "sysdba", "masterkey");
try {
PreparedStatement preparedStatement =
connection.prepareStatement("SELECT testvalue FROM testtable");
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
String value = resultSet.getString(1);
if (value.equals("A")) {
System.out.println("Correct value");
} else if (value.equals("A ")) {
System.out.println("Value with trailing spaces");
} else {
System.out.println("Value: '" + value + "'");
}
System.out.println("Column size: " +
resultSet.getMetaData().getColumnDisplaySize(1));
} else {
System.out.println("Empty ResultSet");
}
} finally {
connection.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Yahoo! Groups Sponsor
ADVERTISEMENT
<http://rd.yahoo.com/SIG=12crllt3b/M=284061.4608947.5773356.1261774/D=egroup
web/S=1705006764:HM/EXP=1077664183/A=2020041/R=2/id=noscript/*http:/taxes.ya
hoo.com/filing.html>
<http://us.a1.yimg.com/us.yimg.com/a/ya/yahoo_finance/alt_lrec_21904.gif>
<http://us.adserver.yahoo.com/l?M=284061.4608947.5773356.1261774/D=egroupweb
/S=:HM/A=2020041/rand=349571035>
_____
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/Firebird-Java/
* To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com
<mailto:Firebird-Java-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service.
[Non-text portions of this message have been removed]
When you use unicode_fss you are able to use all possible char sets for
example chinese,japan,arabic etc.
For this purpose every character in unicode_fss is represented with 3 bytes.
Since latin characters take just 1 byte, there is extra 2 bytes as space.
For example since a chinese character would take 3 bytes, there would be no
extra spaces.
Sezer.
_____
From: Dmitry Shohov [mailto:shofa@...]
Sent: Monday, February 23, 2004 5:38 PM
To: Firebird-Java@yahoogroups.com
Subject: [Firebird-Java] trailing spaces with UNICODE_FSS
Hi!
I created database with default character set UNICODE_FSS. When I
try to get values from columns with char type, JayBird returns strings
with trailing spaces (e.g. if there is column with type char(1) and
value 'A' it returns 'A ' with two spaces at the end).
Is this a bug? Or may be I missed something?
I used JayBird 1.5 beta3 and firebird 1.5.0/1.0.3. OS - Win2000.
Thanks,
Dmitry Shohov
Database script:
CREATE DATABASE 'C:\Projects\bugtest\bugtest.gdb'
USER 'SYSDBA' PASSWORD 'masterkey'
DEFAULT CHARACTER SET UNICODE_FSS;
CREATE TABLE TESTTABLE (
TESTVALUE CHAR(1)
);
INSERT INTO TESTTABLE VALUES('A');
COMMIT;
Java test class:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Test {
public static void main(String[] args) {
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
Connection connection =
DriverManager.getConnection("jdbc:firebirdsql:localhost/3050:c:\\Projects\\b
ugtest\\bugtest.gdb?lc_ctype=UNICODE_FSS", "sysdba", "masterkey");
try {
PreparedStatement preparedStatement =
connection.prepareStatement("SELECT testvalue FROM testtable");
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
String value = resultSet.getString(1);
if (value.equals("A")) {
System.out.println("Correct value");
} else if (value.equals("A ")) {
System.out.println("Value with trailing spaces");
} else {
System.out.println("Value: '" + value + "'");
}
System.out.println("Column size: " +
resultSet.getMetaData().getColumnDisplaySize(1));
} else {
System.out.println("Empty ResultSet");
}
} finally {
connection.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Yahoo! Groups Sponsor
ADVERTISEMENT
<http://rd.yahoo.com/SIG=12crllt3b/M=284061.4608947.5773356.1261774/D=egroup
web/S=1705006764:HM/EXP=1077664183/A=2020041/R=2/id=noscript/*http:/taxes.ya
hoo.com/filing.html>
<http://us.a1.yimg.com/us.yimg.com/a/ya/yahoo_finance/alt_lrec_21904.gif>
<http://us.adserver.yahoo.com/l?M=284061.4608947.5773356.1261774/D=egroupweb
/S=:HM/A=2020041/rand=349571035>
_____
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/Firebird-Java/
* To unsubscribe from this group, send an email to:
Firebird-Java-unsubscribe@yahoogroups.com
<mailto:Firebird-Java-unsubscribe@yahoogroups.com?subject=Unsubscribe>
* Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service.
[Non-text portions of this message have been removed]