0

I pulled out some text values from database, I need to parse this text but when I print text on the console it has some '?' character which are not visible on notepad++ and sqlyog. Below is the sample:

(some character string)??????(another string)???

I need to remove them, but all my efforts went into vain. I used string replaceall method and convert text into char array and again build the text but it is not working. How to remove these '?' characters from text?

Thanks in advance.

user2335004
  • 121
  • 1
  • 10
  • 6
    You're going about this the wrong way. Make sure you are using the proper character encoding. – Sotirios Delimanolis Nov 10 '14 at 16:48
  • what character_Set are you using? maybe try convert character_set? like ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci; – Krish Nov 10 '14 at 16:50
  • And if you want to dig into this more, bear in mind that the "?" characters almost certainly do not represent actual `U003F` question marks in the output. Rather, they're probably used by the software (e.g. Notepad++ or something further up the stack) to indicate a character that they have no glyph for in the current font. If you want to know what these actually are, attach a debugger and inspect the `char` values of the String at these indices. – Andrzej Doyle Nov 10 '14 at 17:27

1 Answers1

0

See the answer in how-can-i-replace-non-printable-unicode-characters-in-java on that topic.

Please note that the nonprintable chars comes most likely from your database table directly or get lost in communication between your Java-application and the table itself.

Community
  • 1
  • 1
Benvorth
  • 7,416
  • 8
  • 49
  • 70