-2

I have a string, but I get these:

Hsbc_$/'\|<?¡!¿&%$#.,-}{][

And how can I escape them so the result I get is the following?

Hsbc_$/'\\|<?\u00A1!\u00BF&%$#.,-}{][

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • I tried to [edit] your question and format your code properly. Please let me know if *input* and *result* match your requirements. – Pshemo May 15 '22 at 20:18
  • 1
    Your given input & expected result didn't match. Please refer below answers if that fulfils your requirement. – Ashish Patil May 15 '22 at 20:21
  • 1
    Re *"I have a string, but I get these"*: Can you [post](https://stackoverflow.com/posts/72251837/edit) the code? (But ***without*** "Edit:", "Update:", or similar - the question should appear as if it was written right now.) Thanks in advance. – Peter Mortensen May 15 '22 at 20:25
  • 2
    "Escape" depends on the context you are using the input. Please [edit] your question to include the context on where/how you need the input be "escaped" and why. – Progman May 15 '22 at 20:26
  • Please don't deface your question. Once you ask a question on this site, your question and its code becomes property of the site as per the terms of service that you agreed to on joining the site. – Hovercraft Full Of Eels May 15 '22 at 23:30
  • @HovercraftFullOfEels It doesn't become the property of SO, but SO does get an irrevocable license. – Mark Rotteveel May 16 '22 at 10:46
  • @MarkRotteveel: ah, thank you. I cannot lie and tell you that I know the differences ... yet – Hovercraft Full Of Eels May 16 '22 at 11:00
  • @HovercraftFullOfEels If you write content on Stack Overflow, you remain the owner and copyright holder of that content. Meaning you are allowed to publish it elsewhere, and even ask money for it. When posting it on Stack Overflow, you give Stack Exchange/Stack Overflow an irrevocable license under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/), meaning that Stack Overflow (and by extension, its users) can do everything allowed by that license. – Mark Rotteveel May 16 '22 at 11:06
  • @MarkRotteveel: Again, thank you! It's clearer now – Hovercraft Full Of Eels May 16 '22 at 11:07
  • @HovercraftFullOfEels And the rollback after defacement is not because SO has a license, but because we don't allow defacement, and because SO (and all its users) has a license, we are free to rollback to a previous version of that content. – Mark Rotteveel May 16 '22 at 11:08

2 Answers2

0

To show the escape sequence rather than the resulting character, you can escape the escape. For example:

Hsbc_$/'\\|<?\\u00A1!\\u00BF&%$#.,-}{][
swmcdonnell
  • 1,381
  • 9
  • 22
0
String a="Hsbc_$/'\\\\|<?\\u00A1!\\u00BF&%$#.,-}{][";
System.out.println(a);

Output:

Hsbc_$/'\\|<?\u00A1!\u00BF&%$#.,-}{][
Ashish Patil
  • 4,428
  • 1
  • 15
  • 36