![]() |
a problem about difference between GNU/Linux and Windows
This is from my .ini parser:
PHP Code:
PHP Code:
I have also pre-processed the string read from the .ini file with this function: PHP Code:
|
Re: a problem about difference between GNU/Linux and Windows
I think I know where is your problem
imagine you have text file made under windows, so end line is CR+LF. And now you will load this .ini file into your parser in windows and linux : WINDOWS : if you call fgets, it will detect newline as CR+LF and end character in your string is \n You will use [length - 2] and everything is allright LINUX : if you call fgets, it reads until LF and string will have \r\n in the end. So you must use [length -3] to skip to section name How to fix it : I use something like this in my parser to skip trailing whitespaces Code:
#include <string> You only check for \n in your trim function. You should also check for \r, or better, check for all whitespace characters by comparing them with space, like I did in previous example more info : http://en.wikipedia.org/wiki/Newline |
All times are GMT +2. The time now is 18:09. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.