Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I can't print accented caracters

 
Rog�rio J. Ribeiro
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm from Brazil-Goi�nia

see a situation:

I can not print accent caracter, they come with interrogation mark.....

see the code:

Blob blob = temp.getBlob("conteudo");
InputStream in = blob.getBinaryStream() ;
byte b = 0;
while (b != -1)
{
b = (byte)in.read();
out.print((char)b);
}

see the print: interrogation signal

Mostrar ?cones Pequenos no Menu Iniciar:I Esta op??o determina como os ?cones ser?o exibidos dentro do menu Iniciar.


I'm used a Firebird database.....

Thanks....
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you writing into the Blob? If the Blob is a UTF-8 encoding, then you'll need to decode using UTF-8 as well (or whatever character set was used to encode). What you're doing is treating each byte as a character, but chars in Java at 2 bytes (Unicode).

Can you post the code that creates the Blob? Or, if it's created outside of Java, can you find out what encoding was used?
 
Rog�rio J. Ribeiro
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CREATE TABLE SUBTOPICO (
ID_SUBTOPICO INTEGER NOT NULL,
ID_TOPICO INTEGER,
DESCRICAO CHAR(100),
CONTEUDO BLOB SUB_TYPE 1 SEGMENT SIZE 80,
ID_PRODUTO INTEGER,
NUMSUBTOPICO INTEGER
);
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry if I wasn't clear. I meant to ask how are the rows containing the BLOBs inserted? Do you use JDBC to insert rows or some other application? If it's Java, then the code must be encoding the 2-byte-character String into a 1-byte array. Typically this is done with UTF-8 (or a modified form), but there are other options.

If some other program (a SQL script you run through isql/sqlplus or an ASP or a data feed from some other database), then you need to figure out how that program is encoding the string.

This Google search will bring up some good information on UTF-8 character encodings. Here's another one about ISO-8859 Latin. It's a tricky subject, but the bottom line is that the encodnig and decoding algorithms must match or you'll get garbage.

A metaphor would be writing a JPEG to disk (pixels -> byte array) and then trying to read it as a GIF (byte array -> pixels). Since the way the "->" is done in each method differs, you won't get an image back.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic