doufu8887 2011-04-21 07:40
浏览 31
已采纳

欧元(html特殊字符)签到selenium / phpunit?

I work on Windows 7, with phpunit & selenium & Firefox.

I have this code:

$value1 = $this->getText("//div[@id= bla bla");
$this->assertEquals($value1, "\u20AC 1,12");

where \u20AC should be the Euro sign. I've also tried €, €, €, but phpunit keeps giving an error, expecting some impossible character combination.

Printing $value1 gives me the same weird combination.

Anybody knows of a way to use, check on HTML special characters or which charset I should/could use?

  • 写回答

1条回答 默认 最新

  • dongri1989 2011-04-21 07:54
    关注

    PHP doesn't support the \u escape you're trying to use, so that's why that's not working.

    One approach would be to use:

    $euro = html_entity_decode('€');
    $this->assertEquals($value1, "$euro 1,12");
    

    Note, the above is kind of nice for readability purposes, although it's verbose and inefficient.

    Other than that, you pretty much have to work out the raw UTF byte sequence, and use one \x escape per byte. For example, the UTF8 byte sequence for U+2022 can be represented in PHP as "\xE2\x80\xA2". I believe the euro sign would be "\xE2\x82\xAC"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?