blob: 03dac7ac315c29672c761dc0a1843382bac21023 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) INRIA - Allan CORNET
* Copyright (C) 2009 - DIGITEO - Antoine ELIAS , Allan CORNET
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
*
*/
#ifndef __CHARENCODING_H__
#define __CHARENCODING_H__
#include <wchar.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "MALLOC.h"
#include "BOOL.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* wcfopen macro for fopen Multibyte char multiplatform
* @param[out] fp file descriptor
* @param[in] x filename
* @param[in] y mode
*/
#ifdef _MSC_VER
#define wcfopen(fp, x,y) \
{\
wchar_t* wfilename = NULL;\
wchar_t* wmode = NULL;\
wfilename = to_wide_string(x);\
wmode = to_wide_string(y);\
if(wfilename == NULL || wmode == NULL){fp = 0;}\
else {fp = _wfopen(wfilename, wmode);}\
if(wfilename != NULL){FREE(wfilename);}\
if(wmode != NULL){FREE(wmode);} \
}
#else
#define wcfopen(fp, x,y) \
{\
fp = fopen(x, y);\
}
#endif
/**
* convert a UTF string to wide char string
* @param[in] UTF string
* @return wide char string converted
*/
wchar_t *to_wide_string(const char *_UTFStr);
/**
* convert a wide char string to UTF-8
* @param[in] wide char string
* @return UTF string converted
*/
char *wide_string_to_UTF8(const wchar_t *_wide);
/*file management with UTF filename*/
#ifdef _MSC_VER
int wcstat(char* filename, struct _stat *st);
#endif
#ifdef _MSC_VER
#define wcsicmp _wcsicmp
#else
int wcsicmp_others(const wchar_t* s1, const wchar_t* s2);
#define wcsicmp wcsicmp_others
#endif
/**
* checks input text is a valid UTF-8 format
* @param[in] string to check
* @return TRUE or FALSE
*/
BOOL IsValidUTF8(const char* pStText);
#ifdef __cplusplus
}
#endif
#endif /* __CHARENCODING_H__ */
|