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 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法