1/* 2** Copyright 2011, Oliver Tappe, zooey@hirschkaefer.de. All rights reserved. 3** Distributed under the terms of the MIT License. 4*/ 5 6#include <wchar_private.h> 7 8 9 int 10__mblen(const char* s, size_t n) 11 { 12 static mbstate_t internalMbState; 13 int rval; 14 15 if (s == NULL) { 16 static const mbstate_t initial; 17 18 internalMbState = initial; 19 20 return 0; // we do not support stateful converters 21 } 22 23 rval = __mbrtowc(NULL, s, n, &internalMbState); 24 25 if (rval == -1 || rval == -2) 26 return -1; 27 28 return rval; 29 } 30 31 32B_DEFINE_WEAK_ALIAS(__mblen, mblen); 33