GithubHelp home page GithubHelp logo

On Windows we get GBK, not UTF8 about koel HOT 8 CLOSED

koel avatar koel commented on May 18, 2024
On Windows we get GBK, not UTF8

from koel.

Comments (8)

phanan avatar phanan commented on May 18, 2024

This is to my knowledge a limitation of PHP 5.x on Windows. Can you try upgrading to PHP 7 as a workaround, and see if it works out?

from koel.

baozijianke avatar baozijianke commented on May 18, 2024

Oh I'm so sorry I didn't attach my system information.
Yes, I followed your wiki to install Koel, so I'm using PHP7.0

Windows10 Edu
Apache/2.4.18 (Win32)
Laravel 5.1
PHP/7.0.0
5.7.10-log - MySQL Community Server (GPL)

from koel.

phanan avatar phanan commented on May 18, 2024

Hmm. You mentioned to have added some code to convert from GBK to UTF8, can you share with me the code?

from koel.

baozijianke avatar baozijianke commented on May 18, 2024

OK.
In fact, in my test I use iconv("GBK","UTF-8//IGNORE",$string) .
I just searched this in Google and had a try.

from koel.

baozijianke avatar baozijianke commented on May 18, 2024

http://www.php.net/manual/en/function.iconv.php
here is the document of iconv.

from koel.

phanan avatar phanan commented on May 18, 2024

Strange. I've just tested in a Windows VM, the function works fine for me:

$file = new SplFileInfo("C:\Users\an\Desktop\中文好歌曲.mp3");
var_dump($file->getPathname()); // string(39) "C:\Users\an\Desktop\中文好歌曲.mp3"

from koel.

baozijianke avatar baozijianke commented on May 18, 2024

em......My test is not the same as yours.
maybe it's the Symfony/Finder 's problem? I'm not sure.
I add 3 songs, one english song, one korean song ,one chinese song.
11

require('vendor/autoload.php');
use Symfony\Component\Finder\Finder;

$finder = new Finder();
$finder->files()->in("D:\MusicBase");

foreach ($finder as $file) {
    // Dump the absolute path
    var_dump(iconv('GBK', 'UTF-8', $file->getRealpath())); // convert
    var_dump($file->getRealpath()); //not convert
}

Below is what I see in chrome. chrome is using UTF-8 by default.

12

Forgive my ugly writings.

from koel.

phanan avatar phanan commented on May 18, 2024

Your sample doesn't work for me though. This appears to be a long-known issue with PHP – Unicode settings on Windows, which unfortunately I don't have enough time to look for a workaround now. I'd suggest you keep the current local fix if it works for you.

from koel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.