neitanod / forceutf8

PHP Class Encoding featuring popular Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strings.
1.63k stars 369 forks source link

How do you use this? #90

Closed shoutinblues closed 3 years ago

shoutinblues commented 4 years ago

This will probably seem to be a stupid question, but I can't figure out how to use this program.

When I run this on the command line: php echo Encoding::fixUTF8("Fédération Camerounaise de Football");

I get an error message: -bash: syntax error near unexpected token `('

I'm using CentOS 7. I am a system administrator with no software development experience. I am not able to look at code and determine how to use it. Could you possibly add some instructions for people at my level?

quyle92 commented 3 years ago

have you put use \ForceUTF8\Encoding; at the top of the page?

neitanod commented 3 years ago

Save this into a file:

https://gist.github.com/neitanod/7ad4bd57fb7e68e5856c93f31cd66b3a

Put it in your path, change it's permissions to make it executable, (and of course make sure you also have the library available in the same folder, or alternatively point to the library file by changing the include in line 4 of the script), and then run:

forceutf8 --help

You'll get:

$ forceutf8 --help
Specifiy the file to convert or pipe some text.

Example 1:
    ls | forceutf8

Example 2:
    forceutf8 input_file.txt  # will output converted text

Example 3:
    forceutf8 input_file.txt replace  # will replace file contents