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
1
vote
0 answers

import org.apache.commons.text not working

I am trying to use the Apache commons-text 1.6 library in my Android Studio project. I have included it and it the commons-lang3 3.8.1 dependancy in my gradle file as shown below: dependencies { implementation fileTree(include: ['*.jar'], dir:…
philp
  • 21
  • 1
  • 5
1
vote
1 answer

StringEscapeUtils displays Japanese in unicode

I'm trying to escape japanese xml to display as normal japanese string and not unicode xml. I can't use apache.commons.lang3 and only apache.commons.lang is preferred. If you have any other suggestions not in this library feel free to share. Thanks…
1
vote
1 answer

Issue in making http call in android due to String format - illegal character in query at index 81

In my application, I have to get the data from JSON service based on TYPE and SUB TYPE selected by user and show the data to user. I know how to make an http request, how to parse the response, but the URL is creating an issue. The URL is like…
Ana
  • 166
  • 1
  • 16
1
vote
1 answer

Correct xml escaping in Java

I need to convert CSV into XML and then to OutputStream. Rule is to convert " into " in my code. Input CSV row: {"Test":"Value"} Expected output: {"Test":"Value"} Current…
1
vote
1 answer

how to escape special characters in xml without escaping xml tags(<>) in java

I want to escape special characters in xml input. I tried StringEscapeUtils.escapeXml10(xmlString) but it ends up escaping xml tags also(<>). For example: Test & Test should normalized to Test&Test Not…
Vikas Chowdhury
  • 737
  • 8
  • 15
1
vote
1 answer

Adding newline in the eventcreate description message while executing from java

We are trying to create windows eventlog by executing following command from java. But unable add newline(\n) in the description(/d). eventcreate /t error /id 100 /l myApp /SO "mysource" /d "this is 1st line of the log \n this is second…
1
vote
0 answers

ÃÂ ÃÂ ÃÂ Special Characters coming in CKEditor parsing html email

I am using CKeditor in Java for sending email functionality. But when I am trying to add an HTML by clicking source, there is no issue in first case but after clicking Next and going Back to the same page, I am getting some Special characters as ÃÂ…
1
vote
1 answer

How to create a String with containing escape sequences in java without using StringEscapeUtils Class?

I want to store "~ s/\n|\s+|.*?=|;//g;" in a string variable. Can anyone help me in this. Thanks in advance.
Monti Chandra
  • 432
  • 5
  • 21
1
vote
0 answers

Java/JSP: preferred way / best practise for escaping Strings

Im working in a project where we use the MVC pattern in a web application. Our views are JSP's. The question i was asking myself: Sometimes i can see JSP's where JSTL (c:out) is used for escaping Strings to HTML for preventing XSS attacks, sometimes…
StephanM
  • 1,350
  • 2
  • 24
  • 50
1
vote
1 answer

SOAPMessage.writeTo() only escapes special chars

I've tried to send some unicode string in a foreign language to the SOAPMessage.writeTo() but it didn't escape it. when i tried to send an XML escaped string StringEscapeUtils.escapeXml() it doubled escape the ampersands. What is the right way to…
Nati
  • 1,034
  • 5
  • 19
  • 46
1
vote
1 answer

JSP can't resolve import of org.apache.commons.lang

I am trying to include the library StringEscapeUtils and everything that I can find indicates that I can import the Apache Org page as follows: <%@ page import="org.apache.commons.lang.StringEscapeUtils" %> however, I can only resolve the URL down…
mobibob
  • 8,670
  • 20
  • 82
  • 131
1
vote
3 answers

pgSQL: am trying to insert into a table using dblink_exec() method, but getting following error

select dblink_exec('hostaddr=59.89.210.56 port=5432 dbname=mydb user=postgres password=****','insert into gtab04 (productid,product,itgrid,itemtype,patentid,taxid,convfact,boxpack,cntid )values (2301,''D PEARL 2000 Caps…
user3422859
1
vote
1 answer

Apache commons StringEscapeUtils.unescapeJava("\\") returns ""

The following code: final String INVALID_ESCAPE="\\"; System.out.println(String.format("'%s' -> '%s'", INVALID_ESCAPE, StringEscapeUtils.unescapeJava(INVALID_ESCAPE))); ... produces: '\' -> '' on the console. Since '\' is not a valid escape I…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
1
vote
1 answer

Any online tool to apply escape characters to a given string for ant script

Hi i want to replace a token value in ant script with following string since we cannot give directly '<','"','%' into an ant script, we need to use escape sequences like…
Anil Tallam
  • 331
  • 4
  • 10
1
vote
2 answers

Absolute fastest possible Java HTML escape function

Basically, this post is a challenge. I've been trying to optimize an HTML escape function today with moderate success. But I know there are some serious Java hackers out there who can probably do this way better than me and I'd love to learn. I've…
Sean
  • 892
  • 1
  • 8
  • 18