Add a string function to copy a wide-char range
This commit is contained in:
parent
77910afe57
commit
c9edf7cf78
@ -43,6 +43,7 @@ void alstr_append_range(al_string *str, const al_string_char_type *from, const a
|
||||
/* Windows-only methods to deal with WideChar strings. */
|
||||
void alstr_copy_wcstr(al_string *str, const wchar_t *from);
|
||||
void alstr_append_wcstr(al_string *str, const wchar_t *from);
|
||||
void alstr_copy_wrange(al_string *str, const wchar_t *from, const wchar_t *to);
|
||||
void alstr_append_wrange(al_string *str, const wchar_t *from, const wchar_t *to);
|
||||
#endif
|
||||
|
||||
|
@ -1149,6 +1149,17 @@ void alstr_append_wcstr(al_string *str, const wchar_t *from)
|
||||
}
|
||||
}
|
||||
|
||||
void alstr_copy_wrange(al_string *str, const wchar_t *from, const wchar_t *to)
|
||||
{
|
||||
int len;
|
||||
if((len=WideCharToMultiByte(CP_UTF8, 0, from, (int)(to-from), NULL, 0, NULL, NULL)) > 0)
|
||||
{
|
||||
VECTOR_RESIZE(*str, len, len+1);
|
||||
WideCharToMultiByte(CP_UTF8, 0, from, (int)(to-from), &VECTOR_FRONT(*str), len+1, NULL, NULL);
|
||||
VECTOR_ELEM(*str, len) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void alstr_append_wrange(al_string *str, const wchar_t *from, const wchar_t *to)
|
||||
{
|
||||
int len;
|
||||
|
Loading…
Reference in New Issue
Block a user