fix mingw build, clean up new warnings
fix mingw build, clean up new warnings

--- a/src/Makefile
+++ b/src/Makefile
@@ -2,14 +2,18 @@
 
 SRCDIR:=	$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
 
+ZLIB_SRCS:= $(sort $(wildcard $(SRCDIR)in_xsf_framework/zlib/*.c))
+ZLIB_OBJS:=	$(subst $(SRCDIR),,$(ZLIB_SRCS:%.c=%.o))
 FRAMEWORK_SRCS:=	$(sort $(wildcard $(SRCDIR)in_xsf_framework/*.cpp))
 FRAMEWORK_OBJS:=	$(subst $(SRCDIR),,$(FRAMEWORK_SRCS:%.cpp=%.o))
 
-in_2sf_SRCS:=	$(wildcard $(SRCDIR)in_2sf/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/addons/*.cpp) \
-	$(wildcard $(SRCDIR)in_2sf/desmume/metaspu/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/metaspu/SoundTouch/*.cpp) \
-	$(wildcard $(SRCDIR)in_2sf/desmume/utils/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/utils/AsmJit/*.cpp) \
-	$(wildcard $(SRCDIR)in_2sf/desmume/utils/AsmJit/base/*.cpp) $(wildcard $(SRCDIR)in_2sf/desmume/utils/AsmJit/x86/*.cpp)
-in_2sf_SRCS:=	$(filter-out $(SRCDIR)in_2sf/desmume/debug.cpp $(SRCDIR)in_2sf/desmume/metaspu/SoundTouch/cpu_detect_x86_win.cpp,$(in_2sf_SRCS))
+in_2sf_SRCS:=	$(wildcard $(SRCDIR)in_2sf/*.cpp \
+	$(SRCDIR)in_2sf/desmume/*.cpp \
+	$(SRCDIR)in_2sf/desmume/*/*.cpp \
+	$(SRCDIR)in_2sf/desmume/*/*/*.cpp \
+	$(SRCDIR)in_2sf/desmume/*/*/*/*.cpp \
+	$(SRCDIR)in_2sf/desmume/*/*/*/*/*.cpp \
+	$(SRCDIR)in_2sf/spu/*.cpp)
 in_gsf_SRCS:=	$(wildcard $(SRCDIR)in_gsf/*.cpp) $(wildcard $(SRCDIR)in_gsf/vbam/apu/*.cpp) $(wildcard $(SRCDIR)in_gsf/vbam/gba/*.cpp)
 in_ncsf_SRCS:=	$(wildcard $(SRCDIR)in_ncsf/*.cpp) $(wildcard $(SRCDIR)in_ncsf/SSEQPlayer/*.cpp)
 in_snsf_SRCS:=	$(wildcard $(SRCDIR)in_snsf/*.cpp) $(wildcard $(SRCDIR)in_snsf/snes9x/*.cpp) $(wildcard $(SRCDIR)in_snsf/snes9x/apu/*.cpp)
@@ -19,12 +23,13 @@
 
 COMPILER:=	$(shell $(CXX) -v 2>/dev/stdout)
 
-MY_CPPFLAGS=	$(CPPFLAGS) -std=gnu++11 -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
-MY_CXXFLAGS=	$(CXXFLAGS) -std=gnu++11 -pipe -Wall -Wctor-dtor-privacy -Wold-style-cast -Wextra -Wno-div-by-zero -Wfloat-equal -Wshadow -Winit-self -Wcast-qual -Wunreachable-code -Wabi -Woverloaded-virtual -Wno-long-long -Wno-switch -I$(SRCDIR)in_xsf_framework -I/g/Code/Winamp\ SDK -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN
+MY_CPPFLAGS=	$(CPPFLAGS) -std=gnu++17 -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN -D_WINDOWS -I$(SRCDIR)in_xsf_framework -I$(SRCDIR)in_xsf_framework/winamp -I$(SRCDIR)in_xsf_framework/zlib -I$(SRCDIR)in_2sf/desmume
+MY_CXXFLAGS=	$(CXXFLAGS) -std=gnu++17 -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN -D_WINDOWS -I$(SRCDIR)in_xsf_framework -I$(SRCDIR)in_xsf_framework/winamp -I$(SRCDIR)in_xsf_framework/zlib -pipe -Wall -Wctor-dtor-privacy -Wold-style-cast -Wextra -Wno-div-by-zero -Wfloat-equal -Wshadow -Winit-self -Wcast-qual -Wunreachable-code -Woverloaded-virtual -Wno-long-long -Wno-switch
+MY_CFLAGS=	$(CFLAGS) -std=gnu17 -DWINAMP_PLUGIN -DUNICODE_INPUT_PLUGIN -D_WINDOWS -I$(SRCDIR)in_xsf_framework -I$(SRCDIR)in_xsf_framework/winamp -I$(SRCDIR)in_xsf_framework/zlib -pipe -Wall -Wextra -Wno-div-by-zero -Wfloat-equal -Wshadow -Winit-self -Wcast-qual -Wunreachable-code -Wno-long-long -Wno-switch
 ifeq (,$(findstring clang,$(COMPILER)))
 MY_CXXFLAGS+=	-Wlogical-op
 endif
-MY_LDFLAGS=	$(LDFLAGS) -lz
+MY_LDFLAGS=	$(LDFLAGS)
 
 DLL_SRCS_template=	$(1)_SRCS:=	$$(sort $$($(1)_SRCS))
 DLL_OBJS_template=	$(1)_OBJS:=	$$(subst $(SRCDIR),,$$($(1)_SRCS:%.cpp=%.o))
@@ -32,8 +37,8 @@
 $(foreach dll,$(DLLS),$(eval $(call DLL_SRCS_template,$(basename $(notdir $(dll))))))
 $(foreach dll,$(DLLS),$(eval $(call DLL_OBJS_template,$(basename $(notdir $(dll))))))
 
-SRCS:=	$(sort $(FRAMEWORK_SRCS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_SRCS)))
-OBJS:=	$(sort $(FRAMEWORK_OBJS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_OBJS)))
+SRCS:=	$(sort $(FRAMEWORK_SRCS) $(ZLIB_SRCS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_SRCS)))
+OBJS:=	$(sort $(FRAMEWORK_OBJS) $(ZLIB_OBJS) $(foreach dll,$(DLLS),$($(basename $(notdir $(dll)))_OBJS)))
 DEPS:=	$(OBJS:%.o=%.d)
 
 .PHONY: all debug clean
@@ -46,17 +51,27 @@
 debug: all
 
 define DLL_template
-$(1): $$(FRAMEWORK_OBJS) $$($$(basename $$(notdir $(1)))_OBJS)
+$(1): $$(FRAMEWORK_OBJS) $$(ZLIB_OBJS) $$($$(basename $$(notdir $(1)))_OBJS)
 	@echo "Linking $$@..."
-	@$$(CXX) -shared -fPIC $$(MY_CXXFLAGS) -o $$@ $$^ $$(MY_LDFLAGS)
+	$$(CXX) -shared -fPIC $$(MY_CXXFLAGS) -o $$@ $$^ $$(MY_LDFLAGS)
 endef
 define SRC_template
+ifeq ($(findstring .cpp,$(1)),.cpp)
 $$(subst $(SRCDIR),,$(1:%.cpp=%.o)): $(1)
 	@echo "Compiling $$<..."
 	@$$(CXX) $$(MY_CXXFLAGS) -o $$(subst $(SRCDIR),,$$@) -c $$<
+else
+$$(subst $(SRCDIR),,$(1:%.c=%.o)): $(1)
+	@echo "Compiling $$<..."
+	@$$(CC) $$(MY_CFLAGS) -o $$(subst $(SRCDIR),,$$@) -c $$<
+endif
 endef
 define DEP_template
+ifeq ($(findstring .cpp,$(1)),.cpp)
 $$(subst $(SRCDIR),,$(1:%.cpp=%.d)): $(1)
+else
+$$(subst $(SRCDIR),,$(1:%.c=%.d)): $(1)
+endif
 	@echo "Calculating depends for $$<..."
 	-@mkdir -p $$(@D)
 	@$$(CXX) $$(MY_CPPFLAGS) -MM -MF $$(subst $(SRCDIR),,$$@).tmp $$<
@@ -69,20 +84,15 @@
 $(foreach src,$(SRCS),$(eval $(call DEP_template,$(src))))
 
 $(subst $(SRCDIR),,$(in_2sf_SRCS:%.cpp=%.d)): MY_CPPFLAGS+=	-msse
-$(in_2sf_OBJS): MY_CXXFLAGS+=	-msse -DHAVE_LIBZ
+$(in_2sf_OBJS): MY_CXXFLAGS+=	-msse -DHAVE_LIBZ -I$(SRCDIR)/in_2sf/desmume
 
-in_2sf/desmume/MMU.o: MY_CXXFLAGS+=	-Wno-shadow
-in_2sf/desmume/utils/AsmJit/base/codegen.o: MY_CXXFLAGS+=	-Wno-unused-value
-in_2sf/desmume/utils/AsmJit/base/runtime.o: MY_CXXFLAGS+=	-Wno-unused-parameter
-in_2sf/desmume/utils/AsmJit/base/vmem.o: MY_CXXFLAGS+=	-Wno-missing-field-initializers -Wno-unused-function
+in_xsf_framework/zlib/%.o: MY_CFLAGS+= -Wno-implicit-fallthrough -Wno-cast-qual
+in_2sf/desmume/%.o: MY_CXXFLAGS+=	-Wno-shadow -Wno-unused-parameter -Wno-unused-value -Wno-unused-variable -Wno-missing-field-initializers -Wno-unused-function -Wno-implicit-fallthrough -Wno-old-style-cast -Wno-deprecated-copy -Wno-class-memaccess -Wno-sign-compare -Wno-float-equal -Wno-unused-but-set-variable
 ifneq (,$(findstring clang,$(COMPILER)))
-in_2sf/desmume/utils/AsmJit/base/vmem.o: MY_CXXFLAGS+=	-Wno-missing-braces
+in_2sf/desmume/%.o: MY_CXXFLAGS+=	-Wno-missing-braces
 endif
-in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: MY_CXXFLAGS+=	-Wno-unused-variable
-ifneq (,$(findstring clang,$(COMPILER)))
-in_2sf/desmume/utils/AsmJit/x86/x86assembler.o: MY_CXXFLAGS+=	-Wno-missing-braces
-endif
-in_2sf/desmume/utils/AsmJit/x86/x86context.o: MY_CXXFLAGS+=	-Wno-unused-parameter -Wno-unused-value -Wno-unused-variable
+in_snsf/snes9x/%.o: MY_CXXFLAGS+= -Wno-implicit-fallthrough -Wno-shift-negative-value
+in_gsf/vbam/apu/Gb_Apu: MY_CXXFLAGS+=	-Wno-implicit-fallthrough
 in_gsf/vbam/gba/GBA-arm.o: MY_CXXFLAGS+=	-Wno-unused-variable
 ifeq (,$(findstring clang,$(COMPILER)))
 in_gsf/vbam/gba/GBA-arm.o: MY_CXXFLAGS+=	-Wno-unused-but-set-variable
@@ -90,7 +100,7 @@
 
 clean:
 	@echo "Cleaning OBJs and DLLs..."
-	-@rm $(OBJS) $(DLLS)
+	-@rm -f $(OBJS) $(DLLS) $(DEPS)
 
 -include $(DEPS)
 

--- a/src/in_2sf/desmume/MMU_timing.h
+++ b/src/in_2sf/desmume/MMU_timing.h
@@ -129,8 +129,8 @@
 	enum { ASSOCIATIVITY = 1 << ASSOCIATIVESHIFT };
 	enum { BLOCKSIZE = 1 << BLOCKSIZESHIFT };
 	enum { TAGSHIFT = SIZESHIFT - ASSOCIATIVESHIFT };
-	enum { TAGMASK = ~0 << TAGSHIFT };
-	enum { BLOCKMASK = (~0 >> (32 - TAGSHIFT)) & (~0 << BLOCKSIZESHIFT) };
+	enum { TAGMASK = ~0U << TAGSHIFT };
+	enum { BLOCKMASK = (~0U >> (32 - TAGSHIFT)) & (~0U << BLOCKSIZESHIFT) };
 	enum { WORDSIZE = sizeof(uint32_t) };
 	enum { WORDSPERBLOCK = (1 << BLOCKSIZESHIFT) / WORDSIZE };
 	enum { DATAPERWORD = WORDSIZE * ASSOCIATIVITY };

--- a/src/in_2sf/desmume/metaspu/metaspu.h
+++ b/src/in_2sf/desmume/metaspu/metaspu.h
@@ -31,6 +31,8 @@
 class ISynchronizingAudioBuffer

 {

 public:

+  virtual ~ISynchronizingAudioBuffer() {}

+

 	virtual void enqueue_samples(s16* buf, int samples_provided) = 0;

 

 	//returns the number of samples actually supplied, which may not match the number requested


--- a/src/in_2sf/desmume/utils/AsmJit/base/operand.h
+++ b/src/in_2sf/desmume/utils/AsmJit/base/operand.h
@@ -1073,7 +1073,8 @@
 }
 
 //! Create void* pointer immediate value operand.
-static ASMJIT_INLINE Imm imm_ptr(void* p) {
+template <typename T>
+static ASMJIT_INLINE Imm imm_ptr(T* p) {
   return Imm(static_cast<int64_t>(reinterpret_cast<intptr_t>(p)));
 }
 

--- a/src/in_2sf/spu/adpcmdecoder.cpp
+++ b/src/in_2sf/spu/adpcmdecoder.cpp
@@ -76,7 +76,7 @@
   }
   std::vector<int16_t> sample;
   sample.reserve(length << 1);
-  for (int i = 0; i < length; i++) {
+  for (uint32_t i = 0; i < length; i++) {
     sample.push_back(getNextSample(data[offset + i] & 0x0f));
     sample.push_back(getNextSample(uint8_t(data[offset + i] & 0xf0) >> 4));
   }

--- a/src/in_2sf/spu/interpolator.cpp
+++ b/src/in_2sf/spu/interpolator.cpp
@@ -71,11 +71,9 @@
   double linear = lerp(left, right, 1.0 + subsample);
   // Projection approaching from the left
   double mLeft = sample - left;
-  double pLeft = sample + mLeft * subsample;
   // Projection approaching from the right
   double negSubsample = 1 - subsample;
   double mRight = right - sample;
-  double pRight = right - mRight * negSubsample;
   int32_t result = (mLeft * negSubsample + mRight * subsample + linear) / 3;
   if ((left <= result) != (result <= right)) {
     // If the result isn't monotonic, fall back to linear

--- a/src/in_2sf/spu/sampledata.cpp
+++ b/src/in_2sf/spu/sampledata.cpp
@@ -9,8 +9,8 @@
   // initializers only
 }
 
-SampleData::SampleData(uint32_t baseAddr, uint16_t loopStart, uint32_t loopLength, Format format)
-: std::vector<int32_t>(), baseAddr(baseAddr), loopStart(loopStart), loopLength(loopLength)
+SampleData::SampleData(uint32_t _baseAddr, uint16_t _loopStart, uint32_t _loopLength, Format format)
+: std::vector<int32_t>(), baseAddr(_baseAddr), loopStart(_loopStart), loopLength(_loopLength)
 {
   if (format == Pcm8) {
     loadPcm8();
@@ -25,11 +25,11 @@
 {
   loopStart += 3;
   resize(loopStart + (loopLength << 2));
-  for (int i = 3; i < loopStart; i++) {
+  for (uint32_t i = 3; i < loopStart; i++) {
     (*this)[i] = int8_t(_MMU_read08<ARMCPU_ARM7, MMU_AT_DEBUG>(baseAddr + i - 3)) << 8;
   }
   uint32_t length = loopStart + loopLength;
-  for (int i = loopStart; i < length; i++) {
+  for (uint32_t i = loopStart; i < length; i++) {
     (*this)[i] = (*this)[length + i] = int8_t(_MMU_read08<ARMCPU_ARM7, MMU_AT_DEBUG>(baseAddr + i - 3)) << 8;
   }
 }
@@ -41,12 +41,12 @@
   loopStart += 3;
   resize(loopStart + (loopLength << 2));
   uint32_t addr = baseAddr;
-  for (int i = 3; i < loopStart; i++) {
+  for (uint32_t i = 3; i < loopStart; i++) {
     (*this)[i] = int16_t(_MMU_read16<ARMCPU_ARM7, MMU_AT_DEBUG>(addr));
     addr += 2;
   }
   uint32_t length = loopStart + loopLength;
-  for (int i = loopStart; i < length; i++) {
+  for (uint32_t i = loopStart; i < length; i++) {
     (*this)[i] = (*this)[length + i] = int16_t(_MMU_read16<ARMCPU_ARM7, MMU_AT_DEBUG>(addr));
     addr += 2;
   }
@@ -62,8 +62,8 @@
     int16_t(_MMU_read16<ARMCPU_ARM7, MMU_AT_DEBUG>(baseAddr)),
     int16_t(_MMU_read16<ARMCPU_ARM7, MMU_AT_DEBUG>(baseAddr + 2))
   );
-  int j = 11;
-  for (int i = 4; i < length; i++) {
+  uint32_t j = 11;
+  for (uint32_t i = 4; i < length; i++) {
     uint8_t data = uint8_t(_MMU_read08<ARMCPU_ARM7, MMU_AT_DEBUG>(baseAddr + i));
     (*this)[j++] = adpcm.getNextSample(uint8_t(data & 0x0f));
     (*this)[j++] = adpcm.getNextSample(uint8_t(data & 0xf0) >> 4);

--- a/src/in_gsf/vbam/gba/GBA.cpp
+++ b/src/in_gsf/vbam/gba/GBA.cpp
@@ -1,4 +1,5 @@
 #include <algorithm>
+#include <string.h>
 #include "GBA.h"
 #include "GBAcpu.h"
 #include "GBAinline.h"

--- a/src/in_ncsf/SSEQPlayer/Channel.cpp
+++ b/src/in_ncsf/SSEQPlayer/Channel.cpp
@@ -455,7 +455,7 @@
 			this->reg.totalLength = this->reg.loopStart + this->reg.length;
 			this->ampl = AMPL_THRESHOLD;
 			this->state = CS_ATTACK;
-			// Fall down
+			// fallthrough
 		case CS_ATTACK:
 		{
 			int newAmpl = this->ampl;

--- a/src/in_ncsf/SSEQPlayer/consts.h
+++ b/src/in_ncsf/SSEQPlayer/consts.h
@@ -35,7 +35,7 @@
 const int FSS_TRACKSTACKSIZE = 3;
 const int AMPL_K = 723;
 const int AMPL_MIN = -AMPL_K;
-const int AMPL_THRESHOLD = AMPL_MIN << 7;
+const int AMPL_THRESHOLD = AMPL_MIN * 128;
 
 inline int SOUND_FREQ(int n) { return -0x1000000 / n; }
 

--- a/src/in_xsf_framework/GNUmakefile
+++ b/src/in_xsf_framework/GNUmakefile
@@ -2,10 +2,10 @@
 	$(WINE) lib.exe /nologo /out:$@ $^
 
 %.obj: %.c
-	$(WINE) cl.exe /nologo /std:c11 /MT /DUNICODE /D_UNICODE /DNDEBUG /DWINAMP_PLUGIN /O2 /EHsc /c /Fo$@ $<
+	$(WINE) cl.exe /nologo /std:c11 /MT /DUNICODE /D_UNICODE /DNDEBUG /DWINAMP_PLUGIN /DUNICODE_INPUT_PLUGIN /O2 /EHsc /c /Fo$@ $<
 
 %.obj: %.cpp $(wildcard *.h) GNUmakefile
-	$(WINE) cl.exe /nologo /std:c++latest /MT /DUNICODE /D_UNICODE /DNDEBUG /DWINAMP_PLUGIN /I zlib /O2 /EHsc /c /Fo$@ $<
+	$(WINE) cl.exe /nologo /std:c++latest /MT /DUNICODE /D_UNICODE /DNDEBUG /DWINAMP_PLUGIN /DUNICODE_INPUT_PLUGIN /I zlib /O2 /EHsc /c /Fo$@ $<
 
 clean:
 	rm -f ../in_xsf_framework.lib *.obj zlib/*.obj winamp/*.obj

--- a/src/in_xsf_framework/codecvt.h
+++ /dev/null
@@ -1,2099 +1,1 @@
-// This comes from llvm's libcxx project. I've copied the code from there (with very minor modifications) for use with GCC and Clang when libcxx isn't being used.
 
-#if (defined(__GNUC__) || defined(__clang__)) && !defined(_LIBCPP_VERSION)
-#pragma once
-
-#include <locale>
-
-namespace std
-{
-
-enum codecvt_mode
-{
-	consume_header = 4,
-	generate_header = 2,
-	little_endian = 1
-};
-
-//                                     Valid UTF ranges
-//     UTF-32               UTF-16                          UTF-8               # of code points
-//                     first      second       first   second    third   fourth
-// 000000 - 00007F  0000 - 007F               00 - 7F                                 127
-// 000080 - 0007FF  0080 - 07FF               C2 - DF, 80 - BF                       1920
-// 000800 - 000FFF  0800 - 0FFF               E0 - E0, A0 - BF, 80 - BF              2048
-// 001000 - 00CFFF  1000 - CFFF               E1 - EC, 80 - BF, 80 - BF             49152
-// 00D000 - 00D7FF  D000 - D7FF               ED - ED, 80 - 9F, 80 - BF              2048
-// 00D800 - 00DFFF                invalid
-// 00E000 - 00FFFF  E000 - FFFF               EE - EF, 80 - BF, 80 - BF              8192
-// 010000 - 03FFFF  D800 - D8BF, DC00 - DFFF  F0 - F0, 90 - BF, 80 - BF, 80 - BF   196608
-// 040000 - 0FFFFF  D8C0 - DBBF, DC00 - DFFF  F1 - F3, 80 - BF, 80 - BF, 80 - BF   786432
-// 100000 - 10FFFF  DBC0 - DBFF, DC00 - DFFF  F4 - F4, 80 - 8F, 80 - BF, 80 - BF    65536
-
-namespace UnicodeConverters
-{
-	inline codecvt_base::result utf16_to_utf8(const uint16_t *frm, const uint16_t *frm_end, const uint16_t *&frm_nxt, uint8_t *to, uint8_t *to_end, uint8_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if (mode & generate_header)
-		{
-			if (to_end - to_nxt < 3)
-				return codecvt_base::partial;
-			*to_nxt++ = 0xEF;
-			*to_nxt++ = 0xBB;
-			*to_nxt++ = 0xBF;
-		}
-		for (; frm_nxt < frm_end; ++frm_nxt)
-		{
-			uint16_t wc1 = *frm_nxt;
-			if (wc1 > Maxcode)
-				return codecvt_base::error;
-			if (wc1 < 0x0080)
-			{
-				if (to_end - to_nxt < 1)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(wc1);
-			}
-			else if (wc1 < 0x0800)
-			{
-				if (to_end - to_nxt < 2)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
-			}
-			else if (wc1 < 0xD800)
-			{
-				if (to_end - to_nxt < 3)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
-			}
-			else if (wc1 < 0xDC00)
-			{
-				if (frm_end - frm_nxt < 2)
-					return codecvt_base::partial;
-				uint16_t wc2 = frm_nxt[1];
-				if ((wc2 & 0xFC00) != 0xDC00)
-					return codecvt_base::error;
-				if (to_end - to_nxt < 4)
-					return codecvt_base::partial;
-				if (((((static_cast<unsigned long>(wc1) & 0x03C0) >> 6) + 1) << 16) + ((static_cast<unsigned long>(wc1) & 0x003F) << 10) + (wc2 & 0x03FF) > Maxcode)
-					return codecvt_base::error;
-				++frm_nxt;
-				uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
-				*to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4) | ((wc1 & 0x003C) >> 2));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc2 & 0x003F));
-			}
-			else if (wc1 < 0xE000)
-				return codecvt_base::error;
-			else
-			{
-				if (to_end - to_nxt < 3)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
-			}
-		}
-		return codecvt_base::ok;
-	}
-
-	inline codecvt_base::result utf16_to_utf8(const uint32_t *frm, const uint32_t *frm_end, const uint32_t *&frm_nxt, uint8_t *to, uint8_t *to_end, uint8_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if (mode & generate_header)
-		{
-			if (to_end - to_nxt < 3)
-				return codecvt_base::partial;
-			*to_nxt++ = 0xEF;
-			*to_nxt++ = 0xBB;
-			*to_nxt++ = 0xBF;
-		}
-		for (; frm_nxt < frm_end; ++frm_nxt)
-		{
-			uint16_t wc1 = static_cast<uint16_t>(*frm_nxt);
-			if (wc1 > Maxcode)
-				return codecvt_base::error;
-			if (wc1 < 0x0080)
-			{
-				if (to_end - to_nxt < 1)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(wc1);
-			}
-			else if (wc1 < 0x0800)
-			{
-				if (to_end - to_nxt < 2)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
-			}
-			else if (wc1 < 0xD800)
-			{
-				if (to_end - to_nxt < 3)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
-			}
-			else if (wc1 < 0xDC00)
-			{
-				if (frm_end - frm_nxt < 2)
-					return codecvt_base::partial;
-				uint16_t wc2 = static_cast<uint16_t>(frm_nxt[1]);
-				if ((wc2 & 0xFC00) != 0xDC00)
-					return codecvt_base::error;
-				if (to_end - to_nxt < 4)
-					return codecvt_base::partial;
-				if (((((static_cast<unsigned long>(wc1) & 0x03C0) >> 6) + 1) << 16) + ((static_cast<unsigned long>(wc1) & 0x003F) << 10) + (wc2 & 0x03FF) > Maxcode)
-					return codecvt_base::error;
-				++frm_nxt;
-				uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
-				*to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4) | ((wc1 & 0x003C) >> 2));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc2 & 0x003F));
-			}
-			else if (wc1 < 0xE000)
-				return codecvt_base::error;
-			else
-			{
-				if (to_end - to_nxt < 3)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
-			}
-		}
-		return codecvt_base::ok;
-	}
-
-	inline codecvt_base::result utf8_to_utf16(const uint8_t *frm, const uint8_t *frm_end, const uint8_t *&frm_nxt, uint16_t *to, uint16_t *to_end, uint16_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
-			frm_nxt += 3;
-		for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
-		{
-			uint8_t c1 = *frm_nxt;
-			if (c1 > Maxcode)
-				return codecvt_base::error;
-			if (c1 < 0x80)
-			{
-				*to_nxt = static_cast<uint16_t>(c1);
-				++frm_nxt;
-			}
-			else if (c1 < 0xC2)
-				return codecvt_base::error;
-			else if (c1 < 0xE0)
-			{
-				if (frm_end - frm_nxt < 2)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				if ((c2 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = t;
-				frm_nxt += 2;
-			}
-			else if (c1 < 0xF0)
-			{
-				if (frm_end - frm_nxt < 3)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				switch (c1)
-				{
-					case 0xE0:
-						if ((c2 & 0xE0) != 0xA0)
-							return codecvt_base::error;
-						break;
-					case 0xED:
-						if ((c2 & 0xE0) != 0x80)
-							return codecvt_base::error;
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return codecvt_base::error;
-				}
-				if ((c3 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = t;
-				frm_nxt += 3;
-			}
-			else if (c1 < 0xF5)
-			{
-				if (frm_end - frm_nxt < 4)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				uint8_t c4 = frm_nxt[3];
-				switch (c1)
-				{
-					case 0xF0:
-						if (c2 < 0x90 || c2 > 0xBF)
-							return codecvt_base::error;
-						break;
-					case 0xF4:
-						if ((c2 & 0xF0) != 0x80)
-							return codecvt_base::error;
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return codecvt_base::error;
-				}
-				if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				if (to_end - to_nxt < 2)
-					return codecvt_base::partial;
-				if ((((static_cast<unsigned long>(c1) & 7) << 18) + ((static_cast<unsigned long>(c2) & 0x3F) << 12) + ((static_cast<unsigned long>(c3) & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = static_cast<uint16_t>(0xD800 | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6) | ((c2 & 0x0F) << 2) | ((c3 & 0x30) >> 4));
-				*++to_nxt = static_cast<uint16_t>(0xDC00 | ((c3 & 0x0F) << 6) | (c4 & 0x3F));
-				frm_nxt += 4;
-			}
-			else
-				return codecvt_base::error;
-		}
-		return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-	}
-
-	inline codecvt_base::result utf8_to_utf16(const uint8_t *frm, const uint8_t *frm_end, const uint8_t *&frm_nxt, uint32_t *to, uint32_t *to_end, uint32_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
-			frm_nxt += 3;
-		for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
-		{
-			uint8_t c1 = *frm_nxt;
-			if (c1 > Maxcode)
-				return codecvt_base::error;
-			if (c1 < 0x80)
-			{
-				*to_nxt = static_cast<uint32_t>(c1);
-				++frm_nxt;
-			}
-			else if (c1 < 0xC2)
-				return codecvt_base::error;
-			else if (c1 < 0xE0)
-			{
-				if (frm_end - frm_nxt < 2)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				if ((c2 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = static_cast<uint32_t>(t);
-				frm_nxt += 2;
-			}
-			else if (c1 < 0xF0)
-			{
-				if (frm_end - frm_nxt < 3)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				switch (c1)
-				{
-					case 0xE0:
-						if ((c2 & 0xE0) != 0xA0)
-							return codecvt_base::error;
-						break;
-					case 0xED:
-						if ((c2 & 0xE0) != 0x80)
-							return codecvt_base::error;
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return codecvt_base::error;
-				}
-				if ((c3 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = static_cast<uint32_t>(t);
-				frm_nxt += 3;
-			}
-			else if (c1 < 0xF5)
-			{
-				if (frm_end - frm_nxt < 4)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				uint8_t c4 = frm_nxt[3];
-				switch (c1)
-				{
-					case 0xF0:
-						if (c2 < 0x90 || c2 > 0xBF)
-							return codecvt_base::error;
-						break;
-					case 0xF4:
-						if ((c2 & 0xF0) != 0x80)
-							return codecvt_base::error;
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return codecvt_base::error;
-				}
-				if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				if (to_end - to_nxt < 2)
-					return codecvt_base::partial;
-				if ((((static_cast<unsigned long>(c1) & 7) << 18) + ((static_cast<unsigned long>(c2) & 0x3F) << 12) + ((static_cast<unsigned long>(c3) & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = static_cast<uint32_t>(0xD800 | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6) | ((c2 & 0x0F) << 2) | ((c3 & 0x30) >> 4));
-				*++to_nxt = static_cast<uint32_t>( 0xDC00 | ((c3 & 0x0F) << 6) | (c4 & 0x3F));
-				frm_nxt += 4;
-			}
-			else
-				return codecvt_base::error;
-		}
-		return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-	}
-
-	inline int utf8_to_utf16_length(const uint8_t *frm, const uint8_t *frm_end, size_t mx, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		auto frm_nxt = frm;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
-			frm_nxt += 3;
-		for (size_t nchar16_t = 0; frm_nxt < frm_end && nchar16_t < mx; ++nchar16_t)
-		{
-			uint8_t c1 = *frm_nxt;
-			if (c1 > Maxcode)
-				break;
-			if (c1 < 0x80)
-				++frm_nxt;
-			else if (c1 < 0xC2)
-				break;
-			else if (c1 < 0xE0)
-			{
-				if (frm_end - frm_nxt < 2 || (frm_nxt[1] & 0xC0) != 0x80)
-					break;
-				uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (frm_nxt[1] & 0x3F));
-				if (t > Maxcode)
-					break;
-				frm_nxt += 2;
-			}
-			else if (c1 < 0xF0)
-			{
-				if (frm_end - frm_nxt < 3)
-					break;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				switch (c1)
-				{
-					case 0xE0:
-						if ((c2 & 0xE0) != 0xA0)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					case 0xED:
-						if ((c2 & 0xE0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-				}
-				if ((c3 & 0xC0) != 0x80)
-					break;
-				if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
-					break;
-				frm_nxt += 3;
-			}
-			else if (c1 < 0xF5)
-			{
-				if (frm_end - frm_nxt < 4 || mx - nchar16_t < 2)
-					break;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				uint8_t c4 = frm_nxt[3];
-				switch (c1)
-				{
-					case 0xF0:
-						if (c2 < 0x90 || c2 > 0xBF)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					case 0xF4:
-						if ((c2 & 0xF0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-				}
-				if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
-					break;
-				if ((((static_cast<unsigned long>(c1) & 7) << 18) + ((static_cast<unsigned long>(c2) & 0x3F) << 12) + ((static_cast<unsigned long>(c3) & 0x3F) << 6) + (c4 & 0x3F)) > Maxcode)
-					break;
-				++nchar16_t;
-				frm_nxt += 4;
-			}
-			else
-				break;
-		}
-		return static_cast<int>(frm_nxt - frm);
-	}
-
-	inline codecvt_base::result ucs4_to_utf8(const uint32_t *frm, const uint32_t *frm_end, const uint32_t *&frm_nxt, uint8_t *to, uint8_t *to_end, uint8_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if (mode & generate_header)
-		{
-			if (to_end - to_nxt < 3)
-				return codecvt_base::partial;
-			*to_nxt++ = 0xEF;
-			*to_nxt++ = 0xBB;
-			*to_nxt++ = 0xBF;
-		}
-		for (; frm_nxt < frm_end; ++frm_nxt)
-		{
-			uint32_t wc = *frm_nxt;
-			if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
-				return codecvt_base::error;
-			if (wc < 0x000080)
-			{
-				if (to_end - to_nxt < 1)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(wc);
-			}
-			else if (wc < 0x000800)
-			{
-				if (to_end - to_nxt < 2)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
-			}
-			else if (wc < 0x010000)
-			{
-				if (to_end - to_nxt < 3)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xE0 | (wc >> 12));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x003F));
-			}
-			else // if (wc < 0x110000)
-			{
-				if (to_end - to_nxt < 4)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xF0 | (wc >> 18));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x03F000) >> 12));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x000FC0) >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x00003F));
-			}
-		}
-		return codecvt_base::ok;
-	}
-
-	inline codecvt_base::result utf8_to_ucs4(const uint8_t *frm, const uint8_t *frm_end, const uint8_t *&frm_nxt, uint32_t *to, uint32_t *to_end, uint32_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
-			frm_nxt += 3;
-		for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
-		{
-			uint8_t c1 = *frm_nxt;
-			if (c1 < 0x80)
-			{
-				if (c1 > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = static_cast<uint32_t>(c1);
-				++frm_nxt;
-			}
-			else if (c1 < 0xC2)
-				return codecvt_base::error;
-			else if (c1 < 0xE0)
-			{
-				if (frm_end - frm_nxt < 2)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				if ((c2 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				uint32_t t = static_cast<uint32_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = t;
-				frm_nxt += 2;
-			}
-			else if (c1 < 0xF0)
-			{
-				if (frm_end - frm_nxt < 3)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				switch (c1)
-				{
-					case 0xE0:
-						if ((c2 & 0xE0) != 0xA0)
-							return codecvt_base::error;
-						break;
-					case 0xED:
-						if ((c2 & 0xE0) != 0x80)
-							return codecvt_base::error;
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return codecvt_base::error;
-				}
-				if ((c3 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				uint32_t t = static_cast<uint32_t>(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) |  (c3 & 0x3F));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = t;
-				frm_nxt += 3;
-			}
-			else if (c1 < 0xF5)
-			{
-				if (frm_end - frm_nxt < 4)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				uint8_t c4 = frm_nxt[3];
-				switch (c1)
-				{
-					case 0xF0:
-						if (c2 < 0x90 || c2 > 0xBF)
-							return codecvt_base::error;
-						break;
-					case 0xF4:
-						if ((c2 & 0xF0) != 0x80)
-							return codecvt_base::error;
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return codecvt_base::error;
-				}
-				if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				uint32_t t = static_cast<uint32_t>(((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) | ((c3 & 0x3F) << 6) |  (c4 & 0x3F));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = t;
-				frm_nxt += 4;
-			}
-			else
-				return codecvt_base::error;
-		}
-		return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-	}
-
-	inline int utf8_to_ucs4_length(const uint8_t *frm, const uint8_t *frm_end, size_t mx, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		auto frm_nxt = frm;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
-			frm_nxt += 3;
-		for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t)
-		{
-			uint8_t c1 = *frm_nxt;
-			if (c1 < 0x80)
-			{
-				if (c1 > Maxcode)
-					break;
-				++frm_nxt;
-			}
-			else if (c1 < 0xC2)
-				break;
-			else if (c1 < 0xE0)
-			{
-				if (frm_end - frm_nxt < 2 || (frm_nxt[1] & 0xC0) != 0x80)
-					break;
-				if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
-					break;
-				frm_nxt += 2;
-			}
-			else if (c1 < 0xF0)
-			{
-				if (frm_end - frm_nxt < 3)
-					break;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				switch (c1)
-				{
-					case 0xE0:
-						if ((c2 & 0xE0) != 0xA0)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					case 0xED:
-						if ((c2 & 0xE0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-				}
-				if ((c3 & 0xC0) != 0x80)
-					break;
-				if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
-					break;
-				frm_nxt += 3;
-			}
-			else if (c1 < 0xF5)
-			{
-				if (frm_end - frm_nxt < 4)
-					break;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				uint8_t c4 = frm_nxt[3];
-				switch (c1)
-				{
-					case 0xF0:
-						if (c2 < 0x90 || c2 > 0xBF)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					case 0xF4:
-						if ((c2 & 0xF0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-				}
-				if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
-					break;
-				if ((((c1 & 0x07u) << 18) | ((c2 & 0x3Fu) << 12) | ((c3 & 0x3Fu) << 6)  |  (c4 & 0x3Fu)) > Maxcode)
-					break;
-				frm_nxt += 4;
-			}
-			else
-				break;
-		}
-		return static_cast<int>(frm_nxt - frm);
-	}
-
-	inline codecvt_base::result ucs2_to_utf8(const uint16_t *frm, const uint16_t *frm_end, const uint16_t *&frm_nxt, uint8_t *to, uint8_t *to_end, uint8_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if (mode & generate_header)
-		{
-			if (to_end - to_nxt < 3)
-				return codecvt_base::partial;
-			*to_nxt++ = 0xEF;
-			*to_nxt++ = 0xBB;
-			*to_nxt++ = 0xBF;
-		}
-		for (; frm_nxt < frm_end; ++frm_nxt)
-		{
-			uint16_t wc = *frm_nxt;
-			if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
-				return codecvt_base::error;
-			if (wc < 0x0080)
-			{
-				if (to_end - to_nxt < 1)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(wc);
-			}
-			else if (wc < 0x0800)
-			{
-				if (to_end - to_nxt < 2)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
-			}
-			else // if (wc <= 0xFFFF)
-			{
-				if (to_end - to_nxt < 3)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(0xE0 | (wc >> 12));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
-				*to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x003F));
-			}
-		}
-		return codecvt_base::ok;
-	}
-
-	inline codecvt_base::result utf8_to_ucs2(const uint8_t *frm, const uint8_t *frm_end, const uint8_t *&frm_nxt, uint16_t *to, uint16_t *to_end, uint16_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
-			frm_nxt += 3;
-		for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
-		{
-			uint8_t c1 = *frm_nxt;
-			if (c1 < 0x80)
-			{
-				if (c1 > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = static_cast<uint16_t>(c1);
-				++frm_nxt;
-			}
-			else if (c1 < 0xC2)
-				return codecvt_base::error;
-			else if (c1 < 0xE0)
-			{
-				if (frm_end - frm_nxt < 2)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				if ((c2 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = t;
-				frm_nxt += 2;
-			}
-			else if (c1 < 0xF0)
-			{
-				if (frm_end - frm_nxt < 3)
-					return codecvt_base::partial;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				switch (c1)
-				{
-					case 0xE0:
-						if ((c2 & 0xE0) != 0xA0)
-							return codecvt_base::error;
-						break;
-					case 0xED:
-						if ((c2 & 0xE0) != 0x80)
-							return codecvt_base::error;
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return codecvt_base::error;
-				}
-				if ((c3 & 0xC0) != 0x80)
-					return codecvt_base::error;
-				uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) |  (c3 & 0x3F));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = t;
-				frm_nxt += 3;
-			}
-			else
-				return codecvt_base::error;
-		}
-		return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-	}
-
-	inline int utf8_to_ucs2_length(const uint8_t *frm, const uint8_t *frm_end, size_t mx, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		auto frm_nxt = frm;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
-			frm_nxt += 3;
-		for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t)
-		{
-			uint8_t c1 = *frm_nxt;
-			if (c1 < 0x80)
-			{
-				if (c1 > Maxcode)
-					break;
-				++frm_nxt;
-			}
-			else if (c1 < 0xC2)
-				break;
-			else if (c1 < 0xE0)
-			{
-				if (frm_end - frm_nxt < 2 || (frm_nxt[1] & 0xC0) != 0x80)
-					break;
-				if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
-					break;
-				frm_nxt += 2;
-			}
-			else if (c1 < 0xF0)
-			{
-				if (frm_end - frm_nxt < 3)
-					break;
-				uint8_t c2 = frm_nxt[1];
-				uint8_t c3 = frm_nxt[2];
-				switch (c1)
-				{
-					case 0xE0:
-						if ((c2 & 0xE0) != 0xA0)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					case 0xED:
-						if ((c2 & 0xE0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-						break;
-					default:
-						if ((c2 & 0xC0) != 0x80)
-							return static_cast<int>(frm_nxt - frm);
-				}
-				if ((c3 & 0xC0) != 0x80)
-					break;
-				if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
-					break;
-				frm_nxt += 3;
-			}
-			else
-				break;
-		}
-		return static_cast<int>(frm_nxt - frm);
-	}
-
-	inline codecvt_base::result ucs4_to_utf16be(const uint32_t *frm, const uint32_t *frm_end, const uint32_t *&frm_nxt, uint8_t *to, uint8_t *to_end, uint8_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if (mode & generate_header)
-		{
-			if (to_end - to_nxt < 2)
-				return codecvt_base::partial;
-			*to_nxt++ = 0xFE;
-			*to_nxt++ = 0xFF;
-		}
-		for (; frm_nxt < frm_end; ++frm_nxt)
-		{
-			uint32_t wc = *frm_nxt;
-			if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
-				return codecvt_base::error;
-			if (wc < 0x010000)
-			{
-				if (to_end - to_nxt < 2)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(wc >> 8);
-				*to_nxt++ = static_cast<uint8_t>(wc);
-			}
-			else
-			{
-				if (to_end - to_nxt < 4)
-					return codecvt_base::partial;
-				uint16_t t = static_cast<uint16_t>(0xD800 | ((((wc & 0x1F0000) >> 16) - 1) << 6) | ((wc & 0x00FC00) >> 10));
-				*to_nxt++ = static_cast<uint8_t>(t >> 8);
-				*to_nxt++ = static_cast<uint8_t>(t);
-				t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
-				*to_nxt++ = static_cast<uint8_t>(t >> 8);
-				*to_nxt++ = static_cast<uint8_t>(t);
-			}
-		}
-		return codecvt_base::ok;
-	}
-
-	inline codecvt_base::result utf16be_to_ucs4(const uint8_t *frm, const uint8_t *frm_end, const uint8_t *&frm_nxt, uint32_t *to, uint32_t *to_end, uint32_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
-			frm_nxt += 2;
-		for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
-		{
-			uint16_t c1 = static_cast<uint16_t>((frm_nxt[0] << 8) | frm_nxt[1]);
-			if ((c1 & 0xFC00) == 0xDC00)
-				return codecvt_base::error;
-			if ((c1 & 0xFC00) != 0xD800)
-			{
-				if (c1 > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = static_cast<uint32_t>(c1);
-				frm_nxt += 2;
-			}
-			else
-			{
-				if (frm_end - frm_nxt < 4)
-					return codecvt_base::partial;
-				uint16_t c2 = static_cast<uint16_t>((frm_nxt[2] << 8) | frm_nxt[3]);
-				if ((c2 & 0xFC00) != 0xDC00)
-					return codecvt_base::error;
-				uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = t;
-				frm_nxt += 4;
-			}
-		}
-		return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-	}
-
-	inline int utf16be_to_ucs4_length(const uint8_t *frm, const uint8_t *frm_end, size_t mx, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		auto frm_nxt = frm;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
-			frm_nxt += 2;
-		for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t)
-		{
-			uint16_t c1 = static_cast<uint16_t>((frm_nxt[0] << 8) | frm_nxt[1]);
-			if ((c1 & 0xFC00) == 0xDC00)
-				break;
-			if ((c1 & 0xFC00) != 0xD800)
-			{
-				if (c1 > Maxcode)
-					break;
-				frm_nxt += 2;
-			}
-			else
-			{
-				if (frm_end - frm_nxt < 4)
-					break;
-				uint16_t c2 = static_cast<uint16_t>((frm_nxt[2] << 8) | frm_nxt[3]);
-				if ((c2 & 0xFC00) != 0xDC00)
-					break;
-				uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
-				if (t > Maxcode)
-					break;
-				frm_nxt += 4;
-			}
-		}
-		return static_cast<int>(frm_nxt - frm);
-	}
-
-	inline codecvt_base::result ucs4_to_utf16le(const uint32_t *frm, const uint32_t *frm_end, const uint32_t *&frm_nxt, uint8_t *to, uint8_t *to_end, uint8_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if (mode & generate_header)
-		{
-			if (to_end - to_nxt < 2)
-				return codecvt_base::partial;
-			*to_nxt++ = 0xFF;
-			*to_nxt++ = 0xFE;
-		}
-		for (; frm_nxt < frm_end; ++frm_nxt)
-		{
-			uint32_t wc = *frm_nxt;
-			if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
-				return codecvt_base::error;
-			if (wc < 0x010000)
-			{
-				if (to_end - to_nxt < 2)
-					return codecvt_base::partial;
-				*to_nxt++ = static_cast<uint8_t>(wc);
-				*to_nxt++ = static_cast<uint8_t>(wc >> 8);
-			}
-			else
-			{
-				if (to_end - to_nxt < 4)
-					return codecvt_base::partial;
-				uint16_t t = static_cast<uint16_t>(0xD800 | ((((wc & 0x1F0000) >> 16) - 1) << 6) | ((wc & 0x00FC00) >> 10));
-				*to_nxt++ = static_cast<uint8_t>(t);
-				*to_nxt++ = static_cast<uint8_t>(t >> 8);
-				t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
-				*to_nxt++ = static_cast<uint8_t>(t);
-				*to_nxt++ = static_cast<uint8_t>(t >> 8);
-			}
-		}
-		return codecvt_base::ok;
-	}
-
-	inline codecvt_base::result utf16le_to_ucs4(const uint8_t *frm, const uint8_t *frm_end, const uint8_t *&frm_nxt, uint32_t *to, uint32_t *to_end, uint32_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
-			frm_nxt += 2;
-		for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
-		{
-			uint16_t c1 = static_cast<uint16_t>((frm_nxt[1] << 8) | frm_nxt[0]);
-			if ((c1 & 0xFC00) == 0xDC00)
-				return codecvt_base::error;
-			if ((c1 & 0xFC00) != 0xD800)
-			{
-				if (c1 > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = static_cast<uint32_t>(c1);
-				frm_nxt += 2;
-			}
-			else
-			{
-				if (frm_end - frm_nxt < 4)
-					return codecvt_base::partial;
-				uint16_t c2 = static_cast<uint16_t>((frm_nxt[3] << 8) | frm_nxt[2]);
-				if ((c2 & 0xFC00) != 0xDC00)
-					return codecvt_base::error;
-				uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
-				if (t > Maxcode)
-					return codecvt_base::error;
-				*to_nxt = t;
-				frm_nxt += 4;
-			}
-		}
-		return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-	}
-
-	inline int utf16le_to_ucs4_length(const uint8_t *frm, const uint8_t *frm_end, size_t mx, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		auto frm_nxt = frm;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
-			frm_nxt += 2;
-		for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t)
-		{
-			uint16_t c1 = static_cast<uint16_t>((frm_nxt[1] << 8) | frm_nxt[0]);
-			if ((c1 & 0xFC00) == 0xDC00)
-				break;
-			if ((c1 & 0xFC00) != 0xD800)
-			{
-				if (c1 > Maxcode)
-					break;
-				frm_nxt += 2;
-			}
-			else
-			{
-				if (frm_end - frm_nxt < 4)
-					break;
-				uint16_t c2 = static_cast<uint16_t>((frm_nxt[3] << 8) | frm_nxt[2]);
-				if ((c2 & 0xFC00) != 0xDC00)
-					break;
-				uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
-				if (t > Maxcode)
-					break;
-				frm_nxt += 4;
-			}
-		}
-		return static_cast<int>(frm_nxt - frm);
-	}
-
-	inline codecvt_base::result ucs2_to_utf16be(const uint16_t *frm, const uint16_t *frm_end, const uint16_t *&frm_nxt, uint8_t *to, uint8_t *to_end, uint8_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if (mode & generate_header)
-		{
-			if (to_end - to_nxt < 2)
-				return codecvt_base::partial;
-			*to_nxt++ = 0xFE;
-			*to_nxt++ = 0xFF;
-		}
-		for (; frm_nxt < frm_end; ++frm_nxt)
-		{
-			uint16_t wc = *frm_nxt;
-			if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
-				return codecvt_base::error;
-			if (to_end - to_nxt < 2)
-				return codecvt_base::partial;
-			*to_nxt++ = static_cast<uint8_t>(wc >> 8);
-			*to_nxt++ = static_cast<uint8_t>(wc);
-		}
-		return codecvt_base::ok;
-	}
-
-	inline codecvt_base::result utf16be_to_ucs2(const uint8_t *frm, const uint8_t *frm_end, const uint8_t *&frm_nxt, uint16_t *to, uint16_t *to_end, uint16_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
-			frm_nxt += 2;
-		for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
-		{
-			uint16_t c1 = static_cast<uint16_t>((frm_nxt[0] << 8) | frm_nxt[1]);
-			if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
-				return codecvt_base::error;
-			*to_nxt = c1;
-			frm_nxt += 2;
-		}
-		return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-	}
-
-	inline int utf16be_to_ucs2_length(const uint8_t *frm, const uint8_t *frm_end, size_t mx, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		auto frm_nxt = frm;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
-			frm_nxt += 2;
-		for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t)
-		{
-			uint16_t c1 = static_cast<uint16_t>((frm_nxt[0] << 8) | frm_nxt[1]);
-			if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
-				break;
-			frm_nxt += 2;
-		}
-		return static_cast<int>(frm_nxt - frm);
-	}
-
-	inline codecvt_base::result ucs2_to_utf16le(const uint16_t *frm, const uint16_t *frm_end, const uint16_t *&frm_nxt, uint8_t *to, uint8_t *to_end, uint8_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if (mode & generate_header)
-		{
-			if (to_end - to_nxt < 2)
-				return codecvt_base::partial;
-			*to_nxt++ = 0xFF;
-			*to_nxt++ = 0xFE;
-		}
-		for (; frm_nxt < frm_end; ++frm_nxt)
-		{
-			uint16_t wc = *frm_nxt;
-			if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
-				return codecvt_base::error;
-			if (to_end - to_nxt < 2)
-				return codecvt_base::partial;
-			*to_nxt++ = static_cast<uint8_t>(wc);
-			*to_nxt++ = static_cast<uint8_t>(wc >> 8);
-		}
-		return codecvt_base::ok;
-	}
-
-	inline codecvt_base::result utf16le_to_ucs2(const uint8_t *frm, const uint8_t *frm_end, const uint8_t *&frm_nxt, uint16_t *to, uint16_t *to_end, uint16_t *&to_nxt, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		frm_nxt = frm;
-		to_nxt = to;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
-			frm_nxt += 2;
-		for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
-		{
-			uint16_t c1 = static_cast<uint16_t>((frm_nxt[1] << 8) | frm_nxt[0]);
-			if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
-				return codecvt_base::error;
-			*to_nxt = c1;
-			frm_nxt += 2;
-		}
-		return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-	}
-
-	inline int utf16le_to_ucs2_length(const uint8_t *frm, const uint8_t *frm_end, size_t mx, unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = static_cast<codecvt_mode>(0))
-	{
-		auto frm_nxt = frm;
-		if ((mode & consume_header) && frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
-			frm_nxt += 2;
-		for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t)
-		{
-			uint16_t c1 = static_cast<uint16_t>((frm_nxt[1] << 8) | frm_nxt[0]);
-			if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
-				break;
-			frm_nxt += 2;
-		}
-		return static_cast<int>(frm_nxt - frm);
-	}
-}
-
-template<> class codecvt<char16_t, char, mbstate_t> : public locale::facet, public codecvt_base
-{
-public:
-	typedef char16_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit codecvt(size_t __refs = 0) : locale::facet(__refs) { }
-
-	result out(state_type &__st, const intern_type *__frm, const intern_type *__frm_end, const intern_type *&__frm_nxt, extern_type *__to, extern_type *__to_end, extern_type *&__to_nxt) const
-	{
-		return this->do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
-	}
-
-	result unshift(state_type &__st, extern_type *__to, extern_type *__to_end, extern_type *&__to_nxt) const
-	{
-		return this->do_unshift(__st, __to, __to_end, __to_nxt);
-	}
-
-	result in(state_type &__st, const extern_type *__frm, const extern_type *__frm_end, const extern_type *&__frm_nxt, intern_type *__to, intern_type *__to_end, intern_type *&__to_nxt) const
-	{
-		return this->do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
-	}
-
-	int encoding() const noexcept
-	{
-		return this->do_encoding();
-	}
-
-	bool always_noconv() const noexcept
-	{
-		return this->do_always_noconv();
-	}
-
-	int length(state_type &__st, const extern_type *__frm, const extern_type *__end, size_t __mx) const
-	{
-		return this->do_length(__st, __frm, __end, __mx);
-	}
-
-	int max_length() const noexcept
-	{
-		return this->do_max_length();
-	}
-
-	static locale::id id;
-
-protected:
-	explicit codecvt(const char *, size_t __refs = 0) : locale::facet(__refs) { }
-
-	~codecvt() { }
-
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint16_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint16_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint16_t *>(to);
-		auto _to_end = reinterpret_cast<uint16_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf8_to_utf16_length(_frm, _frm_end, mx);
-	}
-	virtual int do_max_length() const noexcept { return 4; }
-};
-
-template<> class codecvt<char32_t, char, mbstate_t> : public locale::facet, public codecvt_base
-{
-public:
-	typedef char32_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit codecvt(size_t __refs = 0) : locale::facet(__refs) { }
-
-	result out(state_type &__st, const intern_type *__frm, const intern_type *__frm_end, const intern_type *&__frm_nxt, extern_type *__to, extern_type *__to_end, extern_type *&__to_nxt) const
-	{
-		return this->do_out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
-	}
-
-	result unshift(state_type &__st, extern_type *__to, extern_type *__to_end, extern_type *&__to_nxt) const
-	{
-		return this->do_unshift(__st, __to, __to_end, __to_nxt);
-	}
-
-	result in(state_type &__st, const extern_type *__frm, const extern_type *__frm_end, const extern_type *&__frm_nxt, intern_type *__to, intern_type *__to_end, intern_type *&__to_nxt) const
-	{
-		return this->do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
-	}
-
-	int encoding() const noexcept
-	{
-		return this->do_encoding();
-	}
-
-	bool always_noconv() const noexcept
-	{
-		return this->do_always_noconv();
-	}
-
-	int length(state_type &__st, const extern_type *__frm, const extern_type *__end, size_t __mx) const
-	{
-		return this->do_length(__st, __frm, __end, __mx);
-	}
-
-	int max_length() const noexcept
-	{
-		return this->do_max_length();
-	}
-
-	static locale::id id;
-
-protected:
-	explicit codecvt(const char *, size_t __refs = 0) : locale::facet(__refs) { }
-
-	~codecvt() { }
-
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint32_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint32_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint32_t *>(to);
-		auto _to_end = reinterpret_cast<uint32_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf8_to_ucs4_length(_frm, _frm_end, mx);
-	}
-	virtual int do_max_length() const noexcept { return 4; }
-};
-
-template<class _Elem> class __codecvt_utf8;
-
-template<> class __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef wchar_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-#ifdef _WIN32
-		auto _frm = reinterpret_cast<const uint16_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint16_t *>(frm_end);
-#else
-		auto _frm = reinterpret_cast<const uint32_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint32_t *>(frm_end);
-#endif
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::
-#ifdef _WIN32
-			ucs2_to_utf8
-#else
-			ucs4_to_utf8
-#endif
-			(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-#ifdef _WIN32
-		auto _to = reinterpret_cast<uint16_t *>(to);
-		auto _to_end = reinterpret_cast<uint16_t *>(to_end);
-#else
-		auto _to = reinterpret_cast<uint32_t *>(to);
-		auto _to_end = reinterpret_cast<uint32_t *>(to_end);
-#endif
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::
-#ifdef _WIN32
-			utf8_to_ucs2
-#else
-			utf8_to_ucs4
-#endif
-			(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf8_to_ucs4_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 7;
-		return 4;
-	}
-};
-
-template<> class __codecvt_utf8<char16_t> : public codecvt<char16_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef char16_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint16_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint16_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint16_t *>(to);
-		auto _to_end = reinterpret_cast<uint16_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf8_to_ucs2_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 6;
-		return 3;
-	}
-};
-
-template<> class __codecvt_utf8<char32_t> : public codecvt<char32_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef char32_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint32_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint32_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint32_t *>(to);
-		auto _to_end = reinterpret_cast<uint32_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf8_to_ucs4_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 7;
-		return 4;
-	}
-};
-
-template<class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = static_cast<codecvt_mode>(0)> class codecvt_utf8 : public __codecvt_utf8<_Elem>
-{
-public:
-	explicit codecvt_utf8(size_t __refs = 0) : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) { }
-
-	~codecvt_utf8() { }
-};
-
-template<class _Elem, bool _LittleEndian> class __codecvt_utf16;
-
-template<> class __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef wchar_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint32_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint32_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint32_t *>(to);
-		auto _to_end = reinterpret_cast<uint32_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf16be_to_ucs4_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 6;
-		return 4;
-	}
-};
-
-template<> class __codecvt_utf16<wchar_t, true> : public codecvt<wchar_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef wchar_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint32_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint32_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint32_t *>(to);
-		auto _to_end = reinterpret_cast<uint32_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf16le_to_ucs4_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 6;
-		return 4;
-	}
-};
-
-template<> class __codecvt_utf16<char16_t, false> : public codecvt<char16_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef char16_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint16_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint16_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint16_t *>(to);
-		auto _to_end = reinterpret_cast<uint16_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf16be_to_ucs2_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 4;
-		return 2;
-	}
-};
-
-template<> class __codecvt_utf16<char16_t, true> : public codecvt<char16_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef char16_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint16_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint16_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint16_t *>(to);
-		auto _to_end = reinterpret_cast<uint16_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf16le_to_ucs2_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 4;
-		return 2;
-	}
-};
-
-template<> class __codecvt_utf16<char32_t, false> : public codecvt<char32_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef char32_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint32_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint32_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint32_t *>(to);
-		auto _to_end = reinterpret_cast<uint32_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf16be_to_ucs4_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 6;
-		return 4;
-	}
-};
-
-template<> class __codecvt_utf16<char32_t, true> : public codecvt<char32_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef char32_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint32_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint32_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint32_t *>(to);
-		auto _to_end = reinterpret_cast<uint32_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf16le_to_ucs4_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 6;
-		return 4;
-	}
-};
-
-template<class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = static_cast<codecvt_mode>(0)> class codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian>
-{
-public:
-	explicit codecvt_utf16(size_t __refs = 0) : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) { }
-
-	~codecvt_utf16() { }
-};
-
-template<class _Elem> class __codecvt_utf8_utf16;
-
-template<> class __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef wchar_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint32_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint32_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint32_t *>(to);
-		auto _to_end = reinterpret_cast<uint32_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf8_to_utf16_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 7;
-		return 4;
-	}
-};
-
-template<> class __codecvt_utf8_utf16<char32_t> : public codecvt<char32_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef char32_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint32_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint32_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint32_t *>(to);
-		auto _to_end = reinterpret_cast<uint32_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf8_to_utf16_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 7;
-		return 4;
-	}
-};
-
-template<> class __codecvt_utf8_utf16<char16_t> : public codecvt<char16_t, char, mbstate_t>
-{
-	unsigned long _Maxcode_;
-	codecvt_mode _Mode_;
-public:
-	typedef char16_t intern_type;
-	typedef char extern_type;
-	typedef mbstate_t state_type;
-
-	explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) { }
-protected:
-	virtual result do_out(state_type &, const intern_type *frm, const intern_type *frm_end, const intern_type *&frm_nxt, extern_type *to, extern_type *to_end, extern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint16_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint16_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint8_t *>(to);
-		auto _to_end = reinterpret_cast<uint8_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_in(state_type &, const extern_type *frm, const extern_type *frm_end, const extern_type *&frm_nxt, intern_type *to, intern_type *to_end, intern_type *&to_nxt) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		auto _frm_nxt = _frm;
-		auto _to = reinterpret_cast<uint16_t *>(to);
-		auto _to_end = reinterpret_cast<uint16_t *>(to_end);
-		auto _to_nxt = _to;
-		auto r = UnicodeConverters::utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, this->_Maxcode_, this->_Mode_);
-		frm_nxt = frm + (_frm_nxt - _frm);
-		to_nxt = to + (_to_nxt - _to);
-		return r;
-	}
-	virtual result do_unshift(state_type &, extern_type *to, extern_type *, extern_type *&to_nxt) const
-	{
-		to_nxt = to;
-		return noconv;
-	}
-	virtual int do_encoding() const noexcept { return 0; }
-	virtual bool do_always_noconv() const noexcept { return false; }
-	virtual int do_length(state_type &, const extern_type *frm, const extern_type *frm_end, size_t mx) const
-	{
-		auto _frm = reinterpret_cast<const uint8_t *>(frm);
-		auto _frm_end = reinterpret_cast<const uint8_t *>(frm_end);
-		return UnicodeConverters::utf8_to_utf16_length(_frm, _frm_end, mx, this->_Maxcode_, this->_Mode_);
-	}
-	virtual int do_max_length() const noexcept
-	{
-		if (this->_Mode_ & consume_header)
-			return 7;
-		return 4;
-	}
-};
-
-template<class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = static_cast<codecvt_mode>(0)> class codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem>
-{
-public:
-	explicit codecvt_utf8_utf16(size_t __refs = 0) : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) { }
-
-	~codecvt_utf8_utf16() {}
-};
-
-}
-#endif
-

--- a/src/in_xsf_framework/convert.h
+++ b/src/in_xsf_framework/convert.h
@@ -11,12 +11,7 @@
 #include <sstream>
 #include <typeinfo>
 #include <locale>
-#if (defined(__GNUC__) || defined(__clang__)) && !defined(_LIBCPP_VERSION)
-# include "wstring_convert.h"
-# include "codecvt.h"
-#else
-# include <codecvt>
-#endif
+#include <codecvt>
 #include <vector>
 #include <memory>
 #include <cmath>

--- a/src/in_xsf_framework/wstring_convert.h
+++ /dev/null
@@ -1,184 +1,1 @@
-// This comes from llvm's libcxx project. I've copied the code from there (with very minor modifications) for use with GCC and Clang when libcxx isn't being used.
 
-#if (defined(__GNUC__) || defined(__clang__)) && !defined(_LIBCPP_VERSION)
-#pragma once
-
-#include <memory>
-#include <string>
-#include <locale>
-
-namespace std
-{
-
-template<class _Codecvt, class _Elem = wchar_t, class _Wide_alloc = allocator<_Elem>, class _Byte_alloc = allocator<char>> class wstring_convert
-{
-public:
-	typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string;
-	typedef basic_string<_Elem, char_traits<_Elem>, _Wide_alloc> wide_string;
-	typedef typename _Codecvt::state_type state_type;
-	typedef typename wide_string::traits_type::int_type int_type;
-
-private:
-	byte_string __byte_err_string_;
-	wide_string __wide_err_string_;
-	_Codecvt *__cvtptr_;
-	state_type __cvtstate_;
-	size_t __cvtcount_;
-
-	wstring_convert(const wstring_convert &__wc);
-	wstring_convert& operator=(const wstring_convert &__wc);
-public:
-	wstring_convert(_Codecvt *__pcvt = new _Codecvt) : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) { }
-	wstring_convert(_Codecvt *__pcvt, state_type __state) : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0) { }
-	wstring_convert(const byte_string &__byte_err, const wide_string &__wide_err = wide_string()) : __byte_err_string_(__byte_err), __wide_err_string_(__wide_err), __cvtptr_(new _Codecvt), __cvtstate_(), __cvtcount_(0) { }
-	wstring_convert(wstring_convert &&__wc) : __byte_err_string_(move(__wc.__byte_err_string_)), __wide_err_string_(move(__wc.__wide_err_string_)), __cvtptr_(__wc.__cvtptr_), __cvtstate_(__wc.__cvtstate_), __cvtcount_(__wc.__cvtstate_)
-	{
-		__wc.__cvtptr_ = nullptr;
-	}
-	~wstring_convert() { delete this->__cvtptr_; }
-
-	wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); }
-	wide_string from_bytes(const char *__ptr) { return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr)); }
-	wide_string from_bytes(const byte_string &__str) { return from_bytes(__str.data(), __str.data() + __str.size()); }
-	wide_string from_bytes(const char *__frm, const char *__frm_end)
-	{
-		this->__cvtcount_ = 0;
-		if (this->__cvtptr_)
-		{
-			wide_string __ws(2 * (__frm_end - __frm), _Elem());
-			if (__frm != __frm_end)
-				__ws.resize(__ws.capacity());
-			auto __r = codecvt_base::ok;
-			auto __st = this->__cvtstate_;
-			if (__frm != __frm_end)
-			{
-				auto __to = &__ws[0];
-				auto __to_end = __to + __ws.size();
-				const char *__frm_nxt;
-				do
-				{
-					_Elem *__to_nxt;
-					__r = this->__cvtptr_->in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
-					this->__cvtcount_ += __frm_nxt - __frm;
-					if (__frm_nxt == __frm)
-						__r = codecvt_base::error;
-					else if (__r == codecvt_base::noconv)
-					{
-						__ws.resize(__to - &__ws[0]);
-						// This only gets executed if _Elem is char
-						__ws.append(reinterpret_cast<const _Elem *>(__frm), reinterpret_cast<const _Elem *>(__frm_end));
-						__frm = __frm_nxt;
-						__r = codecvt_base::ok;
-					}
-					else if (__r == codecvt_base::ok)
-					{
-						__ws.resize(__to_nxt - &__ws[0]);
-						__frm = __frm_nxt;
-					}
-					else if (__r == codecvt_base::partial)
-					{
-						ptrdiff_t __s = __to_nxt - &__ws[0];
-						__ws.resize(2 * __s);
-						__to = &__ws[0] + __s;
-						__to_end = &__ws[0] + __ws.size();
-						__frm = __frm_nxt;
-					}
-				} while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
-			}
-			if (__r == codecvt_base::ok)
-				return __ws;
-		}
-		if (this->__wide_err_string_.empty())
-			throw range_error("wstring_convert: from_bytes error");
-		return this->__wide_err_string_;
-	}
-
-	byte_string to_bytes(_Elem __wchar) { return to_bytes(&__wchar, &__wchar + 1); }
-	byte_string to_bytes(const _Elem *__wptr) { return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr)); }
-	byte_string to_bytes(const wide_string &__wstr) { return to_bytes(__wstr.data(), __wstr.data() + __wstr.size()); }
-	byte_string to_bytes(const _Elem *__frm, const _Elem *__frm_end)
-	{
-		this->__cvtcount_ = 0;
-		if (this->__cvtptr_)
-		{
-			byte_string __bs(2 * (__frm_end - __frm), char());
-			if (__frm != __frm_end)
-				__bs.resize(__bs.capacity());
-			auto __r = codecvt_base::ok;
-			auto __st = this->__cvtstate_;
-			if (__frm != __frm_end)
-			{
-				auto __to = &__bs[0];
-				auto __to_end = __to + __bs.size();
-				const _Elem *__frm_nxt;
-				do
-				{
-					char *__to_nxt;
-					__r = this->__cvtptr_->out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
-					this->__cvtcount_ += __frm_nxt - __frm;
-					if (__frm_nxt == __frm)
-						__r = codecvt_base::error;
-					else if (__r == codecvt_base::noconv)
-					{
-						__bs.resize(__to - &__bs[0]);
-						// This only gets executed if _Elem is char
-						__bs.append(reinterpret_cast<const char *>(__frm), reinterpret_cast<const char *>(__frm_end));
-						__frm = __frm_nxt;
-						__r = codecvt_base::ok;
-					}
-					else if (__r == codecvt_base::ok)
-					{
-						__bs.resize(__to_nxt - &__bs[0]);
-						__frm = __frm_nxt;
-					}
-					else if (__r == codecvt_base::partial)
-					{
-						ptrdiff_t __s = __to_nxt - &__bs[0];
-						__bs.resize(2 * __s);
-						__to = &__bs[0] + __s;
-						__to_end = &__bs[0] + __bs.size();
-						__frm = __frm_nxt;
-					}
-				} while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
-			}
-			if (__r == codecvt_base::ok)
-			{
-				auto __s = __bs.size();
-				__bs.resize(__bs.capacity());
-				auto __to = &__bs[0] + __s;
-				auto __to_end = __to + __bs.size();
-				do
-				{
-					char *__to_nxt;
-					__r = this->__cvtptr_->unshift(__st, __to, __to_end, __to_nxt);
-					if (__r == codecvt_base::noconv)
-					{
-						__bs.resize(__to - &__bs[0]);
-						__r = codecvt_base::ok;
-					}
-					else if (__r == codecvt_base::ok)
-						__bs.resize(__to_nxt - &__bs[0]);
-					else if (__r == codecvt_base::partial)
-					{
-						ptrdiff_t __sp = __to_nxt - &__bs[0];
-						__bs.resize(2 * __sp);
-						__to = &__bs[0] + __sp;
-						__to_end = &__bs[0] + __bs.size();
-					}
-				} while (__r == codecvt_base::partial);
-				if (__r == codecvt_base::ok)
-					return __bs;
-			}
-		}
-		if (this->__byte_err_string_.empty())
-			throw range_error("wstring_convert: to_bytes error");
-		return this->__byte_err_string_;
-	}
-
-	size_t converted() const noexcept { return this->__cvtcount_; }
-	state_type state() const { return this->__cvtstate_; }
-};
-
-}
-#endif
-