Questions tagged [stringescapeutils]

69 questions
61
votes
4 answers

How to add org.apache.commons.lang3 to AndroidStudio with gradle

Due to this question I want to use class StringEscapeUntils in package org.apache.commons.lang3. But when I try to import Apache lib by add line compile 'org.apache.commons:commons-collections4:4.0' to build.grade file then can not import the class…
Phan Dinh Thai
  • 2,708
  • 3
  • 24
  • 42
13
votes
4 answers

When i need to escape Html string?

In my legacy project i can see the usage of escapeHtml before string is sent to browser. StringEscapeUtils.escapeHtml(stringBody); I know from api doc what escapeHtml does.here is the example given:- For example: "bread" & "butter" becomes:…
M Sach
  • 30,322
  • 72
  • 198
  • 300
6
votes
4 answers

StringEscapeUtils.escapeXml is converting utf8 characters which it should not

escapeXml function is converting ѭ Ѯ to ѭ Ѯ which I guess it should not. What I read is that it Supports only the five basic XML entities (gt, lt, quot, amp, apos). Is there a function that only converts these five basic xml…
Mady
  • 4,138
  • 5
  • 33
  • 42
5
votes
4 answers

How can I escape all escape-worthy characters in one line of code?

Based on what I see here (accepted answer), it would seem that I could escape strings by doing this: string s = "Woolworth's"; string t = Regex.Escape(s); MessageBox.Show(t); ...but stepping through that, I see no difference between s and t (I…
B. Clay Shannon
  • 1,055
  • 124
  • 399
  • 759
5
votes
2 answers

StringEscapeUtils escapeHtml

Is there a difference between org.apache.commons.lang.StringEscapeUtils.escapeHtml and org.apache.commons.lang3.StringEscapeUtils.escapeHtml4 ?
mathematician
  • 1,462
  • 3
  • 15
  • 20
3
votes
2 answers

Standard library to escape strings (without prepared statements)

I'm searching for a Java standard library to escape strings before using them in a SQL statement. This is mainly to prevent errors and to prevent SQL injection, too. Unfortunately, I will not be able to use prepared statements as is is suggested in…
user1040128
  • 31
  • 1
  • 2
3
votes
2 answers

String contents are same but equals method returns false

I am using StringEscapeUtils to escape and unescape html. I have following code import org.apache.commons.lang.StringEscapeUtils; public class EscapeUtils { public static void main(String args[]) { String string = " 4-Spaces …
Bilal Mirza
  • 2,386
  • 4
  • 28
  • 55
3
votes
1 answer

Escape characters when generating Powershell scripts using C#

I use VS2010, C#, .NET 3.5 for generate Powershell scripts (ps1 files). Then, it is required escape characters for Powershell. Any suggestions about it for develop good method that escape characters? public static partial class StringExtensions …
Kiquenet
  • 13,271
  • 31
  • 133
  • 232
2
votes
0 answers

Bug in apache commons-text 1.2 StringEscapeUtils.unescapeJson

unescapeJson seems to do nothing in 1.2 - It worked correctly in commons-lang3 3.6 The unit tests in the package seem weird to me: @Test public void testUnescapeJson() { final String jsonString = …
ModdyFire
  • 618
  • 2
  • 9
  • 18
2
votes
1 answer

Javac not registering class path and methods correctly, symbol not found

I'm trying to use Apache Commons StringEscapeUtils. I've got this line of code in my import statement, import org.apache.commons.lang3.StringEscapeUtils; I've downloaded apache commons lang, extracted it and moved: commons-lang3-3.4.jar (Note:…
2
votes
2 answers

Java -> Apache Commons StringEscapeUtils -> escapeJavaScript

For a very simple ajax name lookup, I'm sending an id from the client webpage to the server (Tomcat 5.5, Java 5), looking it up in a database and returning a string, which is assigned to a javascript variable back in the client (and then…
Ignacio
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
  • 116
  • 14
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
  • 637
  • 6
  • 13
1
2 3 4 5