2

I have a strange looking problem. I use tinyMCE editor to build a HTML formatted string. String with formatting looks like this:
<p>$      Ag$:      s:          p:</p>
Then I send this piece of code via system() call to my Java class which only prints out position,character and its int value.

POS: 0 CHAR:'<' NUM: 60 
POS: 1 CHAR:'p' NUM: 112 
POS: 2 CHAR:'>' NUM: 62 
POS: 3 CHAR:'$' NUM: 36 
POS: 4 CHAR:' ' NUM: 32 
POS: 5 CHAR:'�' NUM: 194 
POS: 6 CHAR:'�' NUM: 160 
POS: 7 CHAR:' ' NUM: 32 
POS: 8 CHAR:'�' NUM: 194 
POS: 9 CHAR:'�' NUM: 160 
POS: 10 CHAR:' ' NUM: 32 
POS: 11 CHAR:'�' NUM: 194 
POS: 12 CHAR:'�' NUM: 160 
POS: 13 CHAR:'A' NUM: 65 
POS: 14 CHAR:'g' NUM: 103 
POS: 15 CHAR:'$' NUM: 36 
POS: 16 CHAR:':' NUM: 58 
POS: 17 CHAR:' ' NUM: 32 
POS: 18 CHAR:'�' NUM: 194 
POS: 19 CHAR:'�' NUM: 160 
POS: 20 CHAR:' ' NUM: 32 
POS: 21 CHAR:'�' NUM: 194 
POS: 22 CHAR:'�' NUM: 160 
POS: 23 CHAR:' ' NUM: 32 
POS: 24 CHAR:'�' NUM: 194 
POS: 25 CHAR:'�' NUM: 160 
POS: 26 CHAR:'s' NUM: 115 
POS: 27 CHAR:':' NUM: 58 
POS: 28 CHAR:' ' NUM: 32 
POS: 29 CHAR:'�' NUM: 194 
POS: 30 CHAR:'�' NUM: 160 
POS: 31 CHAR:' ' NUM: 32 
POS: 32 CHAR:'�' NUM: 194 
POS: 33 CHAR:'�' NUM: 160 
POS: 34 CHAR:' ' NUM: 32 
POS: 35 CHAR:'�' NUM: 194 
POS: 36 CHAR:'�' NUM: 160 
POS: 37 CHAR:' ' NUM: 32 
POS: 38 CHAR:'�' NUM: 194 
POS: 39 CHAR:'�' NUM: 160 
POS: 40 CHAR:' ' NUM: 32 
POS: 41 CHAR:'�' NUM: 194 
POS: 42 CHAR:'�' NUM: 160 
POS: 43 CHAR:'p' NUM: 112 
POS: 44 CHAR:':' NUM: 58 
POS: 45 CHAR:'<' NUM: 60 
POS: 46 CHAR:'/' NUM: 47 
POS: 47 CHAR:'p' NUM: 112 
POS: 48 CHAR:'>' NUM: 62 

All I need to is preserve all whitespaces in HTML, except those between dollar signs-everything between $$ should be trimed. But when I call trim() on it, nothing happens and the part inside $$ remains untrimed.
I suppose, it's due to a weird space encoding (194, 160)?
Text should be in UTF-8.
Thanks for any kind of help

3
  • 1
    Ok,according to this table, 194 followed by 160 is a nbsp character.
    – MartinM
    Sep 18, 2012 at 9:42
  • another weird thing is that, if I call .replaceAll("\u00A0") on string inside $$, result is: char 160 replaced with " " but 194 still remains.
    – MartinM
    Sep 18, 2012 at 10:08
  • 1
    ok, I resolved this with my colleague. The thing is to tell Java to build string as UTF-8 so multibyte chars can be treated correctly. My mistake was treating each byte as a character.
    – MartinM
    Sep 18, 2012 at 14:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.