View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000436 | LDMud 3.5 | Efuns | public | 2006-01-06 19:40 | 2019-09-24 08:24 |
Reporter | Assigned To | Gnomi | |||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Summary | 0000436: New efun: mbstowcs() | ||||
Description | /*-------------------------------------------------------------------------*/ svalue_t * f_mbstowcs (svalue_t * sp) /* EFUN mbstowcs() * * int *mbstowcs(string str) * * Takes a multibyte string and returns an array of wide characters */ { vector_t *vec; svalue_t *svp; wchar_t *wcdest; char *orig_txt, **orig_txt_ptr, *tmp_txt; size_t tmp_len, len, wcdest_len, orig_len, i; orig_len=mstrsize(sp->u.str); orig_txt=get_txt(sp->u.str); orig_txt_ptr=xalloc(sizeof(char *)); wcdest=xalloc((orig_len+1)*sizeof(wchar_t)); memset(wcdest,0,(orig_len+1)*sizeof(wchar_t)); wcdest_len=0; *orig_txt_ptr=orig_txt; len=0; tmp_txt=orig_txt; while(len<orig_len) { tmp_len=mbsrtowcs(wcdest+wcdest_len, (const char **)orig_txt_ptr, orig_len-len, (mbstate_t *)NULL); if(tmp_len==(size_t)-1) { xfree(orig_txt_ptr); xfree(wcdest); errorf("Bad argument 1 to mbstowcs(): String contains invalid multibyte encoding\n"); } wcdest_len+=tmp_len; len+=strlen(tmp_txt); if(len<orig_len) { len++; wcdest_len++; tmp_txt=orig_txt+len; *orig_txt_ptr=tmp_txt; } } vec=allocate_array(wcdest_len); svp=vec->item; for(i=0;i<wcdest_len;i++) { vec->item[i].type=T_NUMBER; vec->item[i].u.number=(unsigned long int)*(wcdest+i); } xfree(orig_txt_ptr); xfree(wcdest); free_string_svalue(sp); put_array(sp, vec); return sp; } /* f_mbstowcs() */ | ||||
Tags | No tags attached. | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2006-01-06 19:40 |
|
New Issue | |
2006-01-06 19:48 |
|
Note Added: 0000467 | |
2008-07-02 01:15 | Gnomi | Project | LDMud => LDMud 3.5 |
2008-07-02 01:17 | Gnomi | Relationship added | child of 0000432 |
2019-09-24 08:24 | Gnomi | Assigned To | => Gnomi |
2019-09-24 08:24 | Gnomi | Status | new => closed |
2019-09-24 08:24 | Gnomi | Resolution | open => fixed |
2019-09-24 08:24 | Gnomi | Note Added: 0002479 |