FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
dev_file_encod_write_wstr.c
Go to the documentation of this file.
1
/* UTF-encoded wstring file writing */
2
3
#include "
fb.h
"
4
5
int
fb_DevFileWriteEncodWstr
(
FB_FILE
*
handle
,
const
FB_WCHAR
*
buffer
,
size_t
chars )
6
{
7
FILE *fp;
8
char
*encod_buffer;
9
ssize_t bytes;
10
11
FB_LOCK
();
12
13
fp = (FILE*) handle->
opaque
;
14
if
( fp ==
NULL
) {
15
FB_UNLOCK
();
16
return
fb_ErrorSetNum
(
FB_RTERROR_ILLEGALFUNCTIONCALL
);
17
}
18
19
/* convert (note: only wstrings will be written using this function,
20
so there's no binary data to care) */
21
encod_buffer =
fb_WCharToUTF
( handle->
encod
,
22
buffer,
23
chars,
24
NULL
,
25
&bytes );
26
27
if
( encod_buffer !=
NULL
)
28
{
29
/* do write */
30
if
( fwrite( encod_buffer, 1, bytes, fp ) != bytes )
31
{
32
FB_UNLOCK
();
33
return
fb_ErrorSetNum
(
FB_RTERROR_FILEIO
);
34
}
35
36
if
( encod_buffer != (
char
*)buffer )
37
free( encod_buffer );
38
}
39
40
FB_UNLOCK
();
41
42
return
fb_ErrorSetNum
(
FB_RTERROR_OK
);
43
}
rtlib
dev_file_encod_write_wstr.c
Generated on Thu Jan 23 2014 19:40:08 for FreeBASIC by
1.8.4