Questions tagged [stringescapeutils]

'StringEscapeUtils' is a java class in the Text subproject of the Commons project from Apache Software Foundation (ASF). The class was formerly in the Lang subproject. The purpose of the class is to escape and unescape strings for Java, Java Script, HTML and XML. Use this tag for questions regarding the StringEscapeUtils class.

StringEscapeUtils is a java class in the Apache Commons Text project. The class was originally part of the Commons Lang project but was migrated to the Commons Text project. The class is used to convert characters in strings to their equivalent entity and vice-versa. This is known as escaping (or unescaping) characters. For example the [HTML] entity for the & (ampersand) character is &. Hence class StringEscapeUtils contains methods for converting & to & as well as methods for converting & to &. The class also contains methods for escaping and unescaping characters in JavaScript and XML as well as HTML.

82 questions
0
votes
2 answers

StringEscapeUtils is unescaping everything, except newlines (\n)

I try to escape and unescape large text using the StringEscapeUtils from Apache Commons library (v. 1.7) that will be stored and retrieved from a database, in this case a H2 database. Almost every special character is escaped and unescaped…
EnJoY
  • 19
  • 4
0
votes
2 answers

Why is Apache Commons StringEscapeUtils escapeXML10 not working in groovy?

I have a simple groovy script where I want to escape a String for XML... @Grapes(@Grab(group='org.apache.commons', module='commons-lang3',version='3.9')) import org.apache.commons.lang3.StringEscapeUtils def value = "[Apple MacBook Pro with Touch…
AbuMariam
  • 3,282
  • 13
  • 49
  • 82
0
votes
1 answer

Line break (\n) not working in ios when escaped via StringEscapeUtils.escapeJava

I am using compile 'org.apache.commons:commons-lang3:3.4' library to convert emoji from my android app so that it can easily decoded in ios. So in my android app to encode string into unicode i am using this method StringEscapeUtils.escapeJava its…
Suraj Vaishnav
  • 7,777
  • 4
  • 43
  • 46
0
votes
1 answer

HtmlUnit - HTMLParser (page with characters)

I have a resource (a static html page), that I wanna use to test. But, when I get the static page, it comes with some characters encoding. I try with the class StringEscapeUtils but it doesn't work. My function: private HtmlPage getStaticPage()…
laaf
  • 131
  • 7
0
votes
2 answers

Does StringEscapeUtils.escapeHtml(String) escapes $ symbol, too?

I want to escape $ symbol along with other characters like '<', '>' etc. So just wanted to know if StringEscapeUtils supported this. And if not, how can I escape it?
mmk
  • 480
  • 3
  • 10
0
votes
1 answer

Why does my C# escape character not work when being decoded from base 64?

I make a simple printing app where I use \n, \t to text format like tab or new line. It is run perfectly when I input using hard code like this. isi = "ARIEF - JL. ANGGA JAYA II\n\t\t\t\tSTRUK PEMBAYARAN NEXXT MEDIA\n\nIDPEL\t\t\t:…
Ryan Arief
  • 983
  • 2
  • 16
  • 36
0
votes
1 answer

How to escape back slashes '\' in a Java string while ignoring all the places where '\' is used for escaping standard characters?

I want to escape back slashes in a Java string. I tried to use the below code- public static String escapeString(String str) { return str.replace("\\", "\\\\"); } This works like a charm. But, then I noticed that I also have some scenarios where…
Sudip
  • 647
  • 2
  • 7
  • 28
0
votes
1 answer

Escape Japanese strings without turning it into unicode

Currently, we are using StringEscapeUtils.escapeEcmaScript to escape any quotes and tabs etc, it works for English but when it comes to Japanese it encodes all the Japanese characters into unicode, need suggestions on how to maintain Japanese…
photosynthesis
  • 2,632
  • 7
  • 29
  • 45
0
votes
1 answer

How can I convert octal character values in a mixed string with Perl?

I require to use Perl (v5.10) to process strings from another application with embedded octal values for spaces, commas and other non-alphanumeric characters. For example: This - "11624\0040SE\00405th\0040St\0054\0040Suite\0040100", should be this -…
0
votes
1 answer

Escape XML using stringutils commons.lang version3 apply on writer

In the older version of "org.apache.commons.lang"(2.6) StringEscapeUtils, there is a method to escapexml by passing an instance of "java.io.Writer" as one of the parameter. eg: escapeXml(Writer writer, String str) But, in newer version 3…
0
votes
1 answer

StringEscapeUtils.escapeJavaScript Escape Single Quote

I have 2 types of text string that I need to escape: 1) name=ALICE " (double quote) 2) name=ALICE ' (single quote) This is my codes: if (name.indexOf('\'') >= 0){ name=StringEscapeUtils.escapeJavaScript(name); …
Aza Suhaza
  • 220
  • 1
  • 2
  • 15
0
votes
2 answers

Issue with Java StringEscapeUtils.escapeHtml4()

I am trying to escape a string object in my Java application using StringEscapeUtils.escapeHtml4. I am using commons-lang3-3.5.jar library. Below is the format I am trying to do - StringEscapeUtils.escapeHtml4("user001") When I print in console,…
Rashmi Ranjan mallick
  • 6,390
  • 8
  • 42
  • 59
0
votes
0 answers

encode special character java

I'm trying to fix a bug in the code I wrote which convert a srt file to dxfp.xml. it works fine but when there is a special character such as an ampersand it throws an java.lang.NumberFormatException error. I tried to use the StringEscapeUtils…
Calvin
  • 407
  • 1
  • 5
  • 21
0
votes
1 answer

How to send escape sequences via UART, using Embedded C code

I need help in sending a specific escape sequence, using Embedded C. This is my very first topic at stackoverflow! I use this function to write commands through UART: void UART_Write(UARTChannel* channel, uint8_t* data, uint32_t length) The…
S. Lund
  • 3
  • 2
0
votes
1 answer

StringEscapeUtils.unescapeHtml() problem in unescaping HTML entities for Android

This is what I'm doing: public static String htmlToText(String inString) { String noentity=StringEscapeUtils.unescapeHtml(inString); return noentity; } This is where I'm invoking it: String html = "string 1

string…

Sid
  • 9,508
  • 5
  • 39
  • 60