Ali Payandeh
Ali Payandeh

Reputation: 63

Convert Blob to String with Special Character

I am trying to convert a blob variable to string. In DB level, the variable contains XML file with Italian character like

(è, ò, à e ...)

The code that I already used is as below:

   byte[] result = blob.getBytes(1, (int) blob.length());
   String b = new String(result);
   System.out.println(b);

The output cannot resolve the special characters. I guess that is because converting these letters into bytes will eliminate their actual values.

Upvotes: 0

Views: 4377

Answers (1)

Rich
Rich

Reputation: 4248

This is actually depends how you convert your String with non-ASCII characters (Special Characters). You need to specify what encoding you are using when converting it from blob to string.

Upvotes: 0

Related Questions