2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * Helper classes and types for manipulating Unicode
26 #include <xercesc/util/XMLUTF8Transcoder.hpp>
27 #include <xercesc/util/XMLUniDefs.hpp>
29 static const XMLCh UTF8[]={ chLatin_U, chLatin_T, chLatin_F, chDigit_8, chNull };
31 char* xmltooling::toUTF8(const XMLCh* src)
34 unsigned int srclen=XMLString::stringLen(src);
35 XMLUTF8Transcoder t(UTF8, srclen*4 + 1);
36 char* buf=new char[srclen*4 + 1];
37 memset(buf,0,srclen*4 + 1);
40 reinterpret_cast<XMLByte*>(buf),srclen*4,
41 eaten,XMLTranscoder::UnRep_RepChar);
45 XMLCh* xmltooling::fromUTF8(const char* src)
48 unsigned int srclen=strlen(src);
49 XMLUTF8Transcoder t(UTF8, srclen + 1);
50 XMLCh* buf=new XMLCh[srclen + 1];
51 unsigned char* sizes=new unsigned char[srclen];
52 memset(buf,0,(srclen+1)*sizeof(XMLCh));
54 reinterpret_cast<const XMLByte*>(src),srclen,
61 std::ostream& xmltooling::operator<<(std::ostream& ostr, const XMLCh* s)
64 char* p=xmltooling::toUTF8(s);