16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 #include <stdio.h>
26 #include <stddef.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <ctype.h>
30 #include <locale.h>
31 #include <langinfo.h>
32 #include <iconv.h>
33
34 /* Routines to convert back and forth between Platform Encoding and UTF-8 */
35
36 /* Error and assert macros */
37 #define UTF_ERROR(m) utfError(__FILE__, __LINE__, m)
38 #define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
39 #define UTF_DEBUG(x)
40
41 /* Global variables */
42 static iconv_t iconvToPlatform = (iconv_t)-1;
43 static iconv_t iconvFromPlatform = (iconv_t)-1;
44
45 /*
46 * Error handler
47 */
48 static void
49 utfError(char *file, int line, char *message)
50 {
51 (void)fprintf(stderr, "UTF ERROR [\"%s\":%d]: %s\n", file, line, message);
52 abort();
53 }
54
55 /*
56 * Initialize all utf processing.
57 */
|
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 #include <stdio.h>
26 #include <stddef.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <ctype.h>
30 #include <locale.h>
31 #include <langinfo.h>
32 #include <iconv.h>
33
34 /* Routines to convert back and forth between Platform Encoding and UTF-8 */
35
36 /* Use THIS_FILE when it is available. */
37 #ifndef THIS_FILE
38 #define THIS_FILE __FILE__
39 #endif
40
41 /* Error and assert macros */
42 #define UTF_ERROR(m) utfError(THIS_FILE, __LINE__, m)
43 #define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
44 #define UTF_DEBUG(x)
45
46 /* Global variables */
47 static iconv_t iconvToPlatform = (iconv_t)-1;
48 static iconv_t iconvFromPlatform = (iconv_t)-1;
49
50 /*
51 * Error handler
52 */
53 static void
54 utfError(char *file, int line, char *message)
55 {
56 (void)fprintf(stderr, "UTF ERROR [\"%s\":%d]: %s\n", file, line, message);
57 abort();
58 }
59
60 /*
61 * Initialize all utf processing.
62 */
|