Serving UTF-8 content from iRule?
Do iFiles or iRules have any known issues with UTF-8 content? I can't find mention either way in the documentation or online.
I am trying to set up an iRule to serve a maintenance page that contains unicode text. For example:
現在メンテナンス中の為
The actual text is a bit longer but would reveal the site in question.
The utf-8 text cannot be included directly in the iRule because TCL validation fails, complaining of unbalanced braces.
I've tried placing the text in an iFile to get around the TCL validation errors. But then the text delivered to the browser is corrupted. I confirmed with curl that the Content-Type response header indicates UTF-8, and for good measure I set the meta http-equiv in the text of the response as well. I even manually forced Firefox to render the page as UTF-8 text.
When I logged the text returned from the iFile inside the iRule, the same corrupted text appears there. My terminal is set to UTF-8, as confirmed by viewing the text in the source file used to create the iFile.
Has anyone successfully served UTF-8 content from an iRule?
We're running 11.5.1 HF9.
Here is a stripped-down version of the iRule that demonstrates the issue. The referenced iFile contains the Unicode "SNOWMAN" character.
ltm rule utf8_test_minimized {
when HTTP_REQUEST {
set ifilename "unicode-snowman"
if { 1 } {
HTTP::respond 200 content [format {
UTF-8 iRule Test
iFile Test: "%s".
Should look like this: "&9731" (HTML encoded using numeric character reference)
} [ifile get $ifilename]] Content-Type "text/html; charset=utf-8"
log local0. "Test: \"[ifile get $ifilename]\""
return
}
}
}