小编Fal*_*alk的帖子

Javascript 将字符串从 utf-8 转换为 iso-8859-1

我知道这听起来很糟糕,但这是必要的。

\n\n

我在一个使用 utf-8 字符集的网站上有一个 HTML 表单,该表单被发送到使用 iso-8859-1 字符集的服务器。问题是服务器无法正确理解我们在西班牙使用的字符,例如\xc3\xa0, \xc3\xa1, \xc3\xa8, \xc3\xa9, \xc3\xac, \xc3\xad, \xc3\xb2, \xc3\xb3, \xc3\xb9, \xc3\xba, \xc3\xb1, \xc3\xa7等等。因此,如果我搜索类似的内容,art\xc3\xadculo它会找不到任何答案art\xc3\x83\xc2\xadculo

\n\n

我使用 ajaxform ( http://malsup.com/jquery/form/ )发送表单,代码如下:

\n\n
$(".form-wrap, #pagina").on("submit", "form", function(event){\n    event.preventDefault();\n    $(this).ajaxSubmit({\n\n        success: function(data){\n            $("#temp").html(data);\n            //Handle data in #temp div\n            $("#temp").html(\'\');\n        }\n    });\n    return false;\n});\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的问题是:我无法访问搜索服务器,并且无法将整个网站更改为 iso-8859-1 编码,因为这会破坏其他内容。

\n\n

我已经尝试过这些脚本但没有成功:

\n\n\n\n

我可能做的一切都是错的吗?

\n\n

编辑:escape函数对我来说没有用,因为它将这些空格字符转换为%对服务器无用的前缀代码,然后它搜索art%EDculo.

\n\n

使用encodeURIComponent …

javascript jquery encoding utf-8 iso-8859-1

5
推荐指数
1
解决办法
6471
查看次数

Laravel 生成图片并添加内容类型标题

Hi I'm using php's gd library to generate images. I've decided to integrate this into laravel, and I managed to make it work.

My problem is that if laravel sometimes overwrites my content-type header.

This is my controller:

public function imga($algorythm,$w=false,$h=false){
    if (!$w) $w=rand(250,750);
    if (!$h) $h=rand(250,750);
    $im = imagecreatetruecolor($w, $h);

    //Here some fancy function is called
    if (method_exists($this,'img_'.$algorythm)){
        $this->{'img_'.$algorythm}($im,$w,$h);
    }

    header("Content-type: image/png");
    imagepng($im);
    imagedestroy($im);
}
Run Code Online (Sandbox Code Playgroud)

Most of the times if the image is large enough the browser displays it …

php header laravel output

1
推荐指数
1
解决办法
9368
查看次数

标签 统计

encoding ×1

header ×1

iso-8859-1 ×1

javascript ×1

jquery ×1

laravel ×1

output ×1

php ×1

utf-8 ×1