You need to use fputchar / fgetchar with extended ascii if uft8 doesn't work
Now create some functions to make the live easier
pawn Код:
native fwritechar(File: handle, value, bool: utf8 = false) = fputchar;
native freadchar(File: handle, value = 0, bool: utf8 = false) = fgetchar;
stock fwriteEx(File:handle, string[]) {
if(0 <= string[0] <= ucharmax) { // ispacked(string) doesn't seem to work with these characters
for(new i; string[i]; ++i) {
fwritechar(handle, string[i]);
}
} else {
for(new i; string{i}; ++i) {
fwritechar(handle, string{i});
}
}
}
stock freadEx(File:handle, string[], size = sizeof string, bool: pack = false) {
if(pack) {
size *= 4;
for(new i; i < size; ++i) {
if((string{i} = freadchar(handle)) == EOF) {
string{i} = EOS;
break;
}
}
} else {
for(new i; i < size; ++i) {
if((string[i] = freadchar(handle)) == EOF) {
string[i] = EOS;
break;
}
}
}
}
And your code
pawn Код:
new
dest[16],
string[] = !"şьğes", // fwriteEx supports packed and unpacked string
filename[] = "hareket.txt"
;
new File: wFile = fopen(filename, io_write);
if(wFile) {
fwriteEx(wFile, string);
fclose(wFile);
print(string); // print supports both packed and unpacked string instead of printf
}
new File: rFile = fopen(filename, io_read);
if(rFile) {
freadEx(rFile, dest); // freadEx(rFile, dest, .pack = true) to read it as a packed string
fclose(rFile);
print(dest);
}
Well it prints twice the same thing and it is saved correctly in the file, therefor it works
But for me it still looks different in the console, probably because it doesn't support these charaters