Fwrite problem
#1

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?
Reply
#2

http://forum.sa-mp.com/index.php?top...1770#msg801770
Reply
#3

can you help to fix my code? i don't know how to use this "fwrite_utf8(file, your_string, true);"

Reply
#4

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?
Reply
#5

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;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)