Fwrite problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Fwrite problem (
/showthread.php?tid=136805)
Fwrite problem -
billy4601 - 26.03.2010
This is my code. it can work, but the file is not Chinese characters......
pawn Код:
new h;new mins;new sec;new y,m,d;
new str[256];new stringer[256];
getdate(y,m,d);gettime(h,mins,sec);
format(str,256,"-[%02d:%02d:%02d]- 伺服器正式開機\r\n",h,mins,sec);
format(stringer,256,"記錄檔案/伺服器/%d-%d-%d 伺服器開機紀錄.log",y,m,d);
new File:FILE = fopen(stringer,io_append);
fwrite(FILE,str);
fclose(FILE);
Код:
-[01:19:43]- ¦шЄAѕ№Ґї¦Ў¶}°т
What happened? How to fix it up?
Re: Fwrite problem -
dugi - 26.03.2010
http://forum.sa-mp.com/index.php?top...1770#msg801770
Re: Fwrite problem -
billy4601 - 26.03.2010
Quote:
Originally Posted by dugi
|
can you help to fix my code? i don't know how to use this "fwrite_utf8(file, your_string, true);"
Re: Fwrite problem -
billy4601 - 26.03.2010
pawn Код:
new h;new mins;new sec;new y,m,d;
new str[256];new stringer[256];
getdate(y,m,d);gettime(h,mins,sec);
format(str,256,"-[%02d:%02d:%02d]- Server Start\r\n",h,mins,sec);
format(stringer,256,"記錄檔案/伺服器/%d-%d-%d 伺服器開機紀錄.log",y,m,d);
new File:FILE = fopen(stringer,io_append);
fwrite_utf8(FILE,str, true);
//fwrite(FILE,str);
fclose(FILE);
i get one error.....
Код:
(1882) : error 017: undefined symbol "fwrite_utf8"
how to use this?
Re: Fwrite problem -
dugi - 26.03.2010
You need to add this function to your script first:
pawn Код:
stock fwrite_utf8(File:handle, str[], bool:use_utf8)
{
new x=0;
if(!handle) return 0;
while(str[x] != EOS) {
fputchar(handle, str[x], use_utf8);
x++;
}
return x;
}