Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java compiler and §(alt+21)

Tags:

java

I am facing strange issue here. I am trying to use the character § (alt+21) as a delimiter. But when the source is compiled I see that in the class file this character appears as a character similar to a rectangle []. This is failing my tokenisation. Has someone see this before?

String dtr = "abcd§pqrs";   
StringTokenizer st = new StringTokenizer(templateDetails,"§");

in the compiled class file i see the below:

 String dtr = "abcd[]pqrs";   
StringTokenizer st = new StringTokenizer(templateDetails,"[]");

How do I resolve this? TIA

like image 424
hakish Avatar asked Mar 09 '26 02:03

hakish


1 Answers

Use the \u#### syntax to specify a character constant with a specific Unicode number.

This will allow you to specify it in pure ASCII without having to mess with file encodings and compiler behavior.

like image 121
Thorbjørn Ravn Andersen Avatar answered Mar 11 '26 21:03

Thorbjørn Ravn Andersen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!