use more string_view in i18nlangtag
Change-Id: I92e3d60180c31d765994a2212e1c4547c09c93d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133517 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -1455,34 +1455,34 @@ IsoLangGLIBCModifiersEntry const aImplIsoLangGLIBCModifiersEntries[] =
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
LanguageType MsLangId::convertUnxByteStringToLanguage(
|
LanguageType MsLangId::convertUnxByteStringToLanguage(
|
||||||
const OString& rString )
|
std::string_view rString )
|
||||||
{
|
{
|
||||||
OString aLang;
|
OString aLang;
|
||||||
OString aCountry;
|
OString aCountry;
|
||||||
OString aAtString;
|
OString aAtString;
|
||||||
|
|
||||||
sal_Int32 nLangSepPos = rString.indexOf( '_' );
|
size_t nLangSepPos = rString.find( '_' );
|
||||||
sal_Int32 nCountrySepPos = rString.indexOf( '.' );
|
size_t nCountrySepPos = rString.find( '.' );
|
||||||
sal_Int32 nAtPos = rString.indexOf( '@' );
|
size_t nAtPos = rString.find( '@' );
|
||||||
|
|
||||||
if (nCountrySepPos < 0)
|
if (nCountrySepPos == std::string_view::npos)
|
||||||
nCountrySepPos = nAtPos;
|
nCountrySepPos = nAtPos;
|
||||||
if (nCountrySepPos < 0)
|
if (nCountrySepPos == std::string_view::npos)
|
||||||
nCountrySepPos = rString.getLength();
|
nCountrySepPos = rString.size();
|
||||||
|
|
||||||
if (nAtPos >= 0)
|
if (nAtPos != std::string_view::npos)
|
||||||
aAtString = rString.copy( nAtPos+1 );
|
aAtString = OString(rString.substr( nAtPos+1 ));
|
||||||
|
|
||||||
if (((nLangSepPos >= 0) && (nLangSepPos > nCountrySepPos)) || (nLangSepPos < 0))
|
if (((nLangSepPos != std::string_view::npos) && (nLangSepPos > nCountrySepPos)) || (nLangSepPos == std::string_view::npos))
|
||||||
{
|
{
|
||||||
// eg. "el.sun_eu_greek", "tchinese", "es.ISO8859-15"
|
// eg. "el.sun_eu_greek", "tchinese", "es.ISO8859-15"
|
||||||
aLang = rString.copy( 0, nCountrySepPos );
|
aLang = OString(rString.substr( 0, nCountrySepPos ));
|
||||||
}
|
}
|
||||||
else if ( nLangSepPos >= 0 )
|
else if ( nLangSepPos != std::string_view::npos )
|
||||||
{
|
{
|
||||||
// well formed iso names like "en_US.UTF-8", "sh_BA.ISO8859-2@bosnia"
|
// well formed iso names like "en_US.UTF-8", "sh_BA.ISO8859-2@bosnia"
|
||||||
aLang = rString.copy( 0, nLangSepPos );
|
aLang = OString(rString.substr( 0, nLangSepPos ));
|
||||||
aCountry = rString.copy( nLangSepPos+1, nCountrySepPos - nLangSepPos - 1);
|
aCountry = OString(rString.substr( nLangSepPos+1, nCountrySepPos - nLangSepPos - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is a glibc modifier, first look for exact match in modifier table
|
// if there is a glibc modifier, first look for exact match in modifier table
|
||||||
|
@@ -120,7 +120,7 @@ public:
|
|||||||
// TODO: refactor to LanguageTag, used only in
|
// TODO: refactor to LanguageTag, used only in
|
||||||
// i18npool/source/isolang/inunx.cxx to convert Unix locale string
|
// i18npool/source/isolang/inunx.cxx to convert Unix locale string
|
||||||
|
|
||||||
static LanguageType convertUnxByteStringToLanguage( const OString& rString );
|
static LanguageType convertUnxByteStringToLanguage( std::string_view rString );
|
||||||
|
|
||||||
|
|
||||||
static LanguageType resolveSystemLanguageByScriptType( LanguageType nLang, sal_Int16 nType );
|
static LanguageType resolveSystemLanguageByScriptType( LanguageType nLang, sal_Int16 nType );
|
||||||
@@ -245,7 +245,7 @@ public:
|
|||||||
const css::lang::Locale & rLocale );
|
const css::lang::Locale & rLocale );
|
||||||
|
|
||||||
friend LanguageType MsLangId::convertUnxByteStringToLanguage(
|
friend LanguageType MsLangId::convertUnxByteStringToLanguage(
|
||||||
const OString& rString );
|
std::string_view rString );
|
||||||
|
|
||||||
|
|
||||||
/** Convert a Locale to a LanguageType with handling of an empty
|
/** Convert a Locale to a LanguageType with handling of an empty
|
||||||
|
Reference in New Issue
Block a user