Commit 39553f99 authored by Chen Bill's avatar Chen Bill

add BufferIO::CopyWideString

parent e3264fff
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define BUFFERIO_H #define BUFFERIO_H
#include <cstdint> #include <cstdint>
#include <cwchar>
#include "../ocgcore/buffer.h" #include "../ocgcore/buffer.h"
class BufferIO { class BufferIO {
...@@ -49,6 +50,16 @@ public: ...@@ -49,6 +50,16 @@ public:
*pstr = 0; *pstr = 0;
return l; return l;
} }
template<size_t N>
static void CopyString(const char* src, wchar_t(&dst)[N]) {
dst[0] = 0;
std::strncat(dst, src, N - 1);
}
template<size_t N>
static void CopyWideString(const wchar_t* src, wchar_t(&dst)[N]) {
dst[0] = 0;
std::wcsncat(dst, src, N - 1);
}
template<typename T> template<typename T>
static bool CheckUTF8Byte(const T* str, int len) { static bool CheckUTF8Byte(const T* str, int len) {
for (int i = 1; i < len; ++i) { for (int i = 1; i < len; ++i) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment