php - 谷歌在laravel中绘制标题中的字符重音

标签 php mysql laravel charts google-visualization

我使用 Laravel 显示 Google 图表,但不幸的是,带有重音字符的标题显示不正确

     @foreach($barcs as $barc)
      [ '{{$barc->titre}}',  {{$barc->nbr}}],
     @endforeach  

最佳答案

传递给图表 API 的所有显示文本都必须先进行 UTF-8 编码,然后再进行 URL 编码。尝试像这样输出您的标题:

@foreach($barcs as $barc)
    [ '{{htmlentities($barc->titre, ENT_QUOTES, "UTF-8")}}',  {{$barc->nbr}}],
@endforeach

这会将重音字符转换为 Google Charts 可以处理的字符。

someèthing with añ accent 作为 someèthing with añ 发送给 Google口音

如果这不起作用,您能告诉我们您没有正确显示的重音字符是什么吗?

关于php - 谷歌在laravel中绘制标题中的字符重音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42325173/

相关文章:

php - 古怪的 __set() 魔法函数

php - 使用mysql php在结构中显示类别和子类别

c++ - 在 Xcode : -libmysqlcppconn library not found 中使用 MySQL Connector/C++

mysql - 为什么即使我在 POSTMAN 中插入数据,我的数据库仍显示未定义?

php - 加入三个表并计数

php - 如果在使用 php 的 2 个 mysql 查询中的复选框

php - 我如何将 json 从 php 传递到 js 并对其进行操作?

php - CKEditor插入特殊字符

mysql - 用户 'root' @'localhost' Laravel 在 ubuntu 18.04 上的访问被拒绝

php - Laravel 4 子目录 Controller 不加载输入类