Forum Discussion

ashilkin_177320's avatar
ashilkin_177320
Icon for Nimbostratus rankNimbostratus
Aug 20, 2015

Web page in iFile over HTTP::respond content

Hi all! I have a strange situation. I have a html page in iFile storage. The page has cyrillic text and I return this page to clients by HTTP::respond content in iRule. If I use construction like:

HTTP::respond 200  content [ifile get web_page] "Content-Type" "text/html;charset=utf-8"

I have right result and my cyrillic text displayed correct. But if I want to process variables and use constructions like:

set web_page [subst -nobackslashes [ifile get web_page]]
...
HTTP::respond 200 content $web_page "Content-Type" "text/html;charset=utf-8"

my variables work correct, but instead cyrillic words I see something like "К Ñ�ожÐ". I sniff both metod by WireShark and notice that octal codes of chars are difference. For example, in first case I have:

\320\240\320\265\321\201\321\203\321\200\321\201...\r\n

But in second case same string:

 \303\220\302\240\303\220\302\265\303\221\302\201...\r\n

Someone has an idea?

Thank you!

3 Replies

  • Deckard, Thank you for help, but unfortunately it doesn't work in my case. Thanks for F5 support, they found solution - for my case, I should use following construction for generating binary string rather than UTF-8 encoding:

    set web_page [ binary format a* [subst -nobackslashes [ifile get web_page]]]
    ...
    HTTP::respond 200 content $web_page "Content-Type" "text/html;charset=utf-8"
    

    For details - https://www.tcl.tk/man/tcl8.4/TclCmd/binary.htm

    • Ping_Xiong_1567's avatar
      Ping_Xiong_1567
      Historic F5 Account

      This is really cool, I can handle Chinese characters with the ifile.