Convert-Ethiopic
view release on metacpan or search on metacpan
xs/Ethiopic.xs view on Meta::CPAN
}
else {
*date = (int)SvIV ( ST(1) );
*month = (int)SvIV ( ST(2) );
*year = (int)SvIV ( ST(3) );
}
}
else {
hv = (HV*)SvRV( ST(0) );
getDatesFromHash ( hv, date, month, year );
}
}
HV *
newDate ( enum CalendarSys context, int date, int month, long int year, enum Languages langOut )
{
HV * hv = newHV();
hv_store ( hv, "date", 4, newSViv (date), 0 );
hv_store ( hv, "month", 5, newSViv (month), 0 );
hv_store ( hv, "year", 4, newSViv (year), 0 );
hv_store ( hv, "langOut", 7, newSViv (langOut), 0 );
if ( context == ethio )
hv_store ( hv, "calsys", 6, newSVpv ("ethio", 5), 0 );
else
hv_store ( hv, "calsys", 6, newSVpv ("euro", 4), 0 );
/*
* we may want to pass this in the future:
*/
hv_store ( hv, "LCInfo", 6, newSViv(0), 0 );
return ( hv );
}
enum CalendarSys
getContext ( HV * hv )
{
SV ** sv;
sv = hv_fetch ( hv, "calsys", 6, 0 );
return (! strcmp ( "ethio", (char *)SvPV(*sv, PL_na) ) )
? ethio
: euro
;
}
#include "systems/taligent/cvtutf.h"
#include "systems/unicode.h"
FCHAR
xsUTF8ToUnicode ( unsigned char * uchar )
{
FCHAR fch = NIL;
register int i=0, j;
UTF8* utf8Char;
UTF16* utf16Char;
unsigned char extraBytesToRead;
utf8Char = (UTF8 *) calloc ( 4 , sizeof (UTF8) );
utf16Char = (UTF16 *) calloc ( 2 , sizeof (UTF16) );
utf8Char[i++] = uchar[0];
extraBytesToRead = bytesFromUTF8[utf8Char[i-1]];
for (j = 1; j <= extraBytesToRead; j++)
utf8Char[i++] = uchar[j]; /* read next char */
ConvertUTF8toUTF16 ( &utf8Char, utf8Char+i, &utf16Char, utf16Char+1 );
fch = (FCHAR) *--utf16Char;
utf8Char -= i;
free (utf8Char);
free (utf16Char);
return (fch);
}
FCHAR
xs_get_fchar ( I32 ax, int items )
{
dSP;
unsigned char * uchar;
if ( items == 2 )
uchar = (unsigned char *)SvPV(ST(2), PL_na);
else {
HV * hv;
SV ** sv;
hv = (HV*)SvRV( ST(1) );
sv = hv_fetch ( hv, "char", 4, 0 );
uchar = (unsigned char *)SvPV(*sv, PL_na);
}
return ( xsUTF8ToUnicode ( uchar ) );
}
( run in 2.394 seconds using v1.01-cache-2.11-cpan-df04353d9ac )