1*b725e8ebSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b725e8ebSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b725e8ebSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b725e8ebSAndrew Rist * distributed with this work for additional information 6*b725e8ebSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b725e8ebSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b725e8ebSAndrew Rist * "License"); you may not use this file except in compliance 9*b725e8ebSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b725e8ebSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b725e8ebSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b725e8ebSAndrew Rist * software distributed under the License is distributed on an 15*b725e8ebSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b725e8ebSAndrew Rist * KIND, either express or implied. See the License for the 17*b725e8ebSAndrew Rist * specific language governing permissions and limitations 18*b725e8ebSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b725e8ebSAndrew Rist *************************************************************/ 21*b725e8ebSAndrew Rist 22*b725e8ebSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_xmlreader.hxx" 25cdf0e10cSrcweir #include "sal/config.h" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp" 28cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp" 29cdf0e10cSrcweir #include "osl/diagnose.h" 30cdf0e10cSrcweir #include "rtl/textcvt.h" 31cdf0e10cSrcweir #include "rtl/textenc.h" 32cdf0e10cSrcweir #include "rtl/ustring.h" 33cdf0e10cSrcweir #include "rtl/ustring.hxx" 34cdf0e10cSrcweir #include "sal/types.h" 35cdf0e10cSrcweir #include "xmlreader/span.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir namespace xmlreader { 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace { 40cdf0e10cSrcweir 41cdf0e10cSrcweir namespace css = com::sun::star; 42cdf0e10cSrcweir 43cdf0e10cSrcweir } 44cdf0e10cSrcweir 45cdf0e10cSrcweir rtl::OUString Span::convertFromUtf8() const { 46cdf0e10cSrcweir OSL_ASSERT(is()); 47cdf0e10cSrcweir rtl_uString * s = 0; 48cdf0e10cSrcweir if (!rtl_convertStringToUString( 49cdf0e10cSrcweir &s, begin, length, RTL_TEXTENCODING_UTF8, 50cdf0e10cSrcweir (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | 51cdf0e10cSrcweir RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | 52cdf0e10cSrcweir RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir throw css::uno::RuntimeException( 55cdf0e10cSrcweir rtl::OUString( 56cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("cannot convert from UTF-8")), 57cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface >()); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir return rtl::OUString(s, SAL_NO_ACQUIRE); 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir } 63