Linked Questions
29 questions linked to/from How can I replace non-printable Unicode characters in Java?
0 votes
1 answer
3k views
how to trim the Unicode \u0085 character in a String in Java [duplicate]
I'm not able to trim the unicode control character \u0085 in Java. How can you do this? String str = "\u0000\u001f\u0085 hi \n" PrintStream out = new PrintStream(System.out, true, "UTF-8"); out....
1 vote
1 answer
628 views
The regexp "\\P{Print}" used in Java deletes extended-Latin characters [duplicate]
I see that the following line in Java deletes extended-Latin characters, which it should not do: String finalStr = value.replaceAll("\\P{Print}", " "); The \\P{Print} regexp is ...
231 votes
16 answers
358k views
Extract digits from a string in Java
I have a Java String object. I need to extract only digits from it: "123-456-789" -> "123456789" Is there a library function that extracts only digits? Thanks for the answers. ...
229 votes
2 answers
150k views
How to display hidden characters by default (ZERO WIDTH SPACE ie. ​)
I just lost part of my weekend because of this ... joker - zero width space. I just used some snippets from google groups and didn't recognize that there are doubled characters, because Idea (11) didn'...
86 votes
8 answers
26k views
Fastest way to strip all non-printable characters from a Java String
What is the fastest way to strip all non-printable characters from a String in Java? So far I've tried and measured on 138-byte, 131-character String: String's replaceAll() - slowest method 517009 ...
25 votes
3 answers
45k views
How to replace non-printable unicode characters (Javascript)
I've already wasted a good amount of time dealing with strings (generated by some other source) and I found out that the problem was that the strings have non-printable characters. Today I am dealing ...
21 votes
4 answers
35k views
AssertEquals(String, String) ComparisonFailure when contents are identical
I'm facing the following scenario: I have an app that spits everything out to the STDOUT (simple company test) and I'm trying to JUnit this. My problem is, when I run the application, it returns me ...
11 votes
1 answer
25k views
How to remove \u200B (Zero Length Whitespace Unicode Character) from String in Java?
My application is using Spring Integration for email polling from Outlook mailbox. As, it is receiving the String (email body)from an external system (Outlook), So I have no control over it. For ...
8 votes
4 answers
36k views
How to remove non-valid unicode characters from strings in java
I am using the CoreNLP Neural Network Dependency Parser to parse some social media content. Unfortunately, the file contains characters which are, according to fileformat.info, not valid unicode ...
1 vote
2 answers
3k views
How to clean a csv file from weird characters (e.g. SUB)?
I am uploading csv files using jdbc to teradata. Everything used to be fine, until recently I came across a csv file that had some weird characters and my code failed to upload . I opened the csv ...
0 votes
2 answers
11k views
JSON Parsing Error: Unexpected character (s) at position 226025
I saw similar question on Stackoverflow but none of them helped me to solve my issue. So, I am asking for help as I have tried to find out what is the reason behind the error I am getting but failed. ...
4 votes
3 answers
3k views
Java Integer.valueOf produces NumberFormatException for valid number within range
In Java, I make the call: String chunkSizeAsString = responseString.split(DOUBLE_NEW_LINE)[1] .split(SINGLE_NEW_LINE)[0]; System.out.println("Trying to get integer value of '" + chunkSizeAsString ...
3 votes
3 answers
1k views
java.lang.NumberFormatException: Invalid int: "5"
I try to read a .txt file which is basically a CSV file which is located in the Assets folder in Android. In the first row there is the number of row and columns of the file The rest is composed by ...
4 votes
2 answers
2k views
Escape hex like \u... in kotlin strings
I have a string "\ufffd\ufffd hello\n" i have a code like this fun main() { val bs = "\ufffd\ufffd hello\n" println(bs) // �� hello } and i want to see "\...
0 votes
1 answer
3k views
How to detect special characters like ^A in a byte array
A file consisting of special characters like ^A is stored in a byte array.how to detect these special characters and remove them?