diff options
author | Chris Robinson <[email protected]> | 2018-01-13 02:03:13 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-01-13 02:03:13 -0800 |
commit | c9edf7cf7827dbbdbd2d76087a280f6d8aff4126 (patch) | |
tree | 0a2f97c657b6f9e3dda2df2f64ef529e733db3e0 /Alc/helpers.c | |
parent | 77910afe577458595a3fccd2487fcb567067be58 (diff) |
Add a string function to copy a wide-char range
Diffstat (limited to 'Alc/helpers.c')
-rw-r--r-- | Alc/helpers.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Alc/helpers.c b/Alc/helpers.c index 5d39f3d8..ac0826f2 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -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; |