The online racing simulator
PHP -> Config files
(9 posts, started )
PHP -> Config files
Hello,

I'm making a web based server control panel for lfs.

Now I have a problem with the special chars in lfs...

An example:

I want to add • in a server name,

so I open the .cfg file and put • at the "/host=" part

When I saved the config file and start the server, • shows as hostname in lfsworld.

When I open the web config editor it shows : � where the dot should be.

When I replace the � in the config panel with a •, then it reads fine in the control panel.

When I now restart the server, it shows • on lfsworld...

Anyone know how to fix this?

ps: I used fwrite() an fread() to write & read the config files.
Are you using Unicode16 or ascii?
Quote from elmohellno :Are you using Unicode16 or ascii?

I'm a bit amateur so don't know everything about programming in Php.. so tbh I have no idea...

Tho this is what I use to read & write config files:
Read:

<?php 
$fh 
fopen($file'r');
$configContent fread($fhfilesize($file));
fclose($fh);
?>

Write:

<?php 
$fh 
fopen($file'w');
fwrite($fh$configUpdated);
fclose($fh);
?>

#4 - Silox
I'm not sure, but I think he means the site's codec. I searched around a bit and ended up here:

fwrite($fh,utf8_encode($configUpdated));

I have no experience using fwrite in PHP, so I don't know if this is the right way. I had problems with UTF-8 encoding in VB.net's write function with LFS' special characters.

Veel geluk ermee!
Bonne chance!
header('Content-type: text/html; charset=ISO-8859-1');

did the trick... Noticed it by coincidence i made a new php file without th e <html> tags and it displayed the circles right...

So did right click properties in firefox and it said charset is ISO-8859-1..

Tho this is prolly not the right way (but it works for now)...

If anyone has a better solution, let me know.

Thanks already!
Bedankt hé
#6 - Silox
I think that's the right way, I already thought about that but got confused with the problems I had
Yeah, it's basically how the browser is interpreting the file. Placeing the correct header, or adding the correct information into the <head> section of the HTML document will fix that error with a meta tag.
Quote from Dygear :Yeah, it's basically how the browser is interpreting the file. Placeing the correct header, or adding the correct information into the <head> section of the HTML document will fix that error with a meta tag.

Yeah, but still I don't know, how come only header('Content-type: text/html; charset=ISO-8859-1'); works and not header('Content-type: text/html; charset=UTF-8');

I thought most files from lfs worked with unicode thing...

PHP -> Config files
(9 posts, started )
FGED GREDG RDFGDR GSFDG