Menu

Escape Unicode strings to SimplyHTML?

2016-02-18
2016-02-20
  • Robertonisola

    Robertonisola - 2016-02-18

    Hi friends,

    Suppose I have this unicode string 'Nhật Bản'.

    When I pass it to function HtmlUtils.unicodeToHTMLUnicodeEntity(), the output I get is:

    However, if I just type this string in a note panel, the corresponding text in the 'HTML Code View' tab of SimplyHTML is:

    I know these two results are equivalent, because 0x1ead = 7853, and 0x1ea3 = 7843. However, I need a function to convert the initial string 'Nhật Bản' to the exact HTML string displayed by SimplyHTML. Could you please tell me how to do this?

    FYI, this is my attempt to implement the 'highlighted results' feature when searching for some texts in all notes (which I already mentioned in another topic). I am almost there. I believe this is the final challenge.

    Thank you very much.

     

    Last edit: Robertonisola 2016-02-18
  • Dimitry Polivaev

    I think SimplyHTML uses javax.swing.text.html.HTMLWriter.output(char[], int, int) to create this output. Just set a break point in debugger.

     
    • Robertonisola

      Robertonisola - 2016-02-20

      Hi Dimitry, Thank you for your answer. I have searched the internet to figure out how to use javax.swing.text.html.HTMLWriter.output(char[], int, int), but it's a little complicated.

      I wonder is there any function in the API of Freeplane that does the following:

      input: a Unicode string.
      output: the escaped version of the input unicode string, which is in the form displayed by SimplyHTML.

      For anyone who is interested in this topic, but still feels my description of the output unclear, please read my first post to understand what I mean.

      Thank you guys.

       
  • Robertonisola

    Robertonisola - 2016-02-20

    Hi guys,

    I found a java library named unbescape. Using this library solved my problem :)

    Thank you.