如何设置我的代码下面charset CODE 737 php-laravel

时间:2016-06-29 10:26:05

标签: php laravel utf-8 iconv

public function downloadTXT()
{

    $txt = "";
    $datas = User::select('home_id','home_firstname','home_lastname')
        ->orderBy('home_id','desc')
        ->take(Input::get('number'))
        ->get();

    foreach($datas as $data){
        $txt .= 100000+$data['home_id'].' '.$data['home_firstname'].' '.$data['home_lastname'].PHP_EOL;
    }
    //$txtname = 'mytxt.txt';

    $headers = ['Content-type: text/plain',
                'test'=>'YoYo',
                'Content-Disposition'=>sprintf('attachment; filename="%s"', Input::get('name')),
                'X-BooYAH'=>'WorkyWorky',
                //'Content-Length'=>sizeof($datas)
                ];

    return Response::make($txt , 200, $headers );

}

我如何才能将代码为737的utf-8字符集iconv,我甚至不知道像#utf-8'

这样的符号

CODE PAGE 737 =>链接

修改

$txt = mb_convert_encoding($txt,'cp737'); 

这不起作用....不承认它!

1 个答案:

答案 0 :(得分:0)

1)所以我发现解决方案希望这对某人有所帮助。首先,我发现PHP和其他语言的功能有它" iconv "这是众所周知的!

2)其次,您必须找到所需的编码Net.name of the coding you need for windows

3)最后,这里是使编码不同所需的代码 在返回之前,您必须转换txt文件

$txt = iconv("UTF-8","cp737","$txt");

所以这意味着从 utf-8 cp737 ,而thirst参数是我们创建的txt文件!