Gamestudio Links
Zorro Links
Newest Posts
bestwinsite
by winsite3. 05/30/24 04:10
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 722 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
file_str_write doesn't support unicode #419553
03/11/13 15:29
03/11/13 15:29
Joined: Nov 2012
Posts: 62
Istanbul
T
Talemon Offline OP
Junior Member
Talemon  Offline OP
Junior Member
T

Joined: Nov 2012
Posts: 62
Istanbul
Hey there, I need to write some unicode text to a text file but it seems to me that file_str_write does not support unicode strings. Is there a way to accomplish this or do I need to write my strings byte by byte?

Re: file_str_write doesn't support unicode [Re: Talemon] #419563
03/11/13 18:09
03/11/13 18:09
Joined: Aug 2008
Posts: 394
Germany
Benni003 Offline
Senior Member
Benni003  Offline
Senior Member

Joined: Aug 2008
Posts: 394
Germany
Hi Talemon,

just go to this post: Unicode text to string

Re: file_str_write doesn't support unicode [Re: Benni003] #419578
03/12/13 07:36
03/12/13 07:36
Joined: Nov 2012
Posts: 62
Istanbul
T
Talemon Offline OP
Junior Member
Talemon  Offline OP
Junior Member
T

Joined: Nov 2012
Posts: 62
Istanbul
Originally Posted By: Benni003
Hi Talemon,

just go to this post: Unicode text to string

Hey there, I'm talking about writing unicode strings to a file, not reading. I'm juggling with unicode strings now, it's just that I'm having trouble writing them.

Aynways, I wrote some utility functions to do the job, in case anyone needs:

Code:
function U_file_str_write(FILE* arg_fp, STRING* arg_str)
{
	if(U_Assert(arg_fp, "U_file_str_write: arg_fp") != 0) return;
	if(U_Assert(arg_str, "U_file_str_write: arg_str") != 0) return;
	int i;
	for(i = 0; i < str_len(arg_str) * 2; i++)
	{
		var ch = (arg_str->chars)[i];
		file_asc_write(arg_fp, ch);
	}
}

function U_file_str_writeline(FILE* arg_fp, STRING* arg_str)
{
	if(U_Assert(arg_fp, "U_file_str_write: arg_fp") != 0) return;
	U_file_str_write(arg_fp, arg_str);
	file_asc_write(arg_fp, 0x0a); // \n first byte
	file_asc_write(arg_fp, 0x00); // \n second byte
}

function U_file_str_writebom(FILE* arg_fp)
{
	if(U_Assert(arg_fp, "U_file_str_writebom: arg_fp") != 0) return;
	file_asc_write(arg_fp, 0xff); \\ 
	file_asc_write(arg_fp, 0xfe); \\ Byte-order mark(BOM) for UCS-2 LE
}

FILE* U_file_create_write(char* arg_filename)
{
	FILE* fp = file_open_write(arg_filename);
	U_file_str_writebom(fp);
	return fp;
}


Re: file_str_write doesn't support unicode [Re: Talemon] #419600
03/12/13 13:06
03/12/13 13:06
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
If you have the unicode text already, you can also write it to a file with Word: Save As, File Type: Text, Coding: Unicode.


Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1