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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
/* ----------------------------------------------------------------------------
* eucjp.c
* ----------------------------------------------------------------------------
* Mastering programmed by YAMASHINA Hio
*
* Copyright 2008 YAMASHINA Hio
* ----------------------------------------------------------------------------
* $Id$
* ------------------------------------------------------------------------- */
#include "unijp.h"
#include "unijp_build.h"
#include "xs_compat.h"
#define chk_sjis _uj_xs_chk_sjis
#define chk_eucjp _uj_xs_chk_eucjp
#define xs_eucjp_sjis(decl) _uj_xs_eucjp_sjis(const uj_conv_t* sv_str, uj_conv_t* __out)
#define xs_sjis_eucjp(decl) _uj_xs_sjis_eucjp(const uj_conv_t* sv_str, uj_conv_t* __out)
#include "../eucjp.c"
#undef xs_eucjp_sjis
#undef xs_sjis_eucjp
#define xs_eucjp_sjis(in,out) _uj_xs_eucjp_sjis(in,out)
#define xs_sjis_eucjp(in,out) _uj_xs_sjis_eucjp(in,out)
uj_conv_t* _uj_sjis_to_eucjp(const uj_conv_t* in, uj_conv_t* out)
{
uj_conv_t* ret;
ret = xs_sjis_eucjp(in, out);
/* ret == out|NULL */
return ret;
}
uj_conv_t* _uj_eucjp_to_sjis(const uj_conv_t* in, uj_conv_t* out)
{
uj_conv_t* ret;
ret = xs_eucjp_sjis(in, out);
/* ret == out|NULL */
return ret;
}
uj_conv_t* _uj_utf8_to_eucjp(const uj_conv_t* in, uj_conv_t* out)
{
uj_conv_t* conv_ret;
uj_conv_t* tmp_ret;
uj_conv_t tmp_out;
tmp_ret = _uj_utf8_to_sjis(in, &tmp_out);
if( tmp_ret!=NULL )
{
conv_ret = _uj_sjis_to_eucjp(&tmp_out, out);
_uj_conv_move_owner(out, &tmp_out);
_uj_conv_free_buffer(&tmp_out);
}else
{
conv_ret = NULL;
}
return conv_ret;
}
uj_conv_t* _uj_eucjp_to_utf8(const uj_conv_t* in, uj_conv_t* out)
{
uj_conv_t* conv_ret;
uj_conv_t* tmp_ret;
uj_conv_t tmp_out;
tmp_ret = _uj_eucjp_to_sjis(in, &tmp_out);
if( tmp_ret!=NULL )
{
conv_ret = _uj_sjis_to_utf8(&tmp_out, out);
_uj_conv_move_owner(out, &tmp_out);
_uj_conv_free_buffer(&tmp_out);
}else
{
conv_ret = NULL;
}
return conv_ret;
}
/* ----------------------------------------------------------------------------
: uj_to_eucjp(uj, &len).
+--------------------------------------------------------------------------- */
uj_uint8* uj_to_eucjp(const unijp_t* uj, uj_size_t* p_len)
{
uj_conv_t in;
uj_conv_t out;
uj_conv_t* conv_ret;
uj_uint8* ret_buf;
_uj_conv_set_const(&in, uj->alloc, uj->data, uj->data_len);
conv_ret = _uj_utf8_to_eucjp(&in, &out);
if( conv_ret!=NULL )
{
_uj_conv_own_string(conv_ret);
ret_buf = conv_ret->buf;
if( p_len )
{
*p_len = conv_ret->buf_len;
}
}else
{
ret_buf = NULL;
}
return ret_buf;
}
/* ----------------------------------------------------------------------------
* End of File.
* ------------------------------------------------------------------------- */
|