1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#include "address.h"
7#include "addressformatscript_p.h"
8
9using namespace KContacts;
10
11AddressFormatScript::ScriptType AddressFormatScript::detect(const QString &s)
12{
13 for (auto c : s) {
14 switch (c.script()) {
15 case QChar::Script_Arabic:
16 return AddressFormatScript::ArabicLikeScript;
17 case QChar::Script_Han:
18 return AddressFormatScript::HanLikeScript;
19 case QChar::Script_Hangul:
20 case QChar::Script_Thai:
21 return AddressFormatScript::HangulLikeScript;
22 default:
23 break;
24 }
25 }
26 return AddressFormatScript::LatinLikeScript;
27}
28
29AddressFormatScript::ScriptType AddressFormatScript::detect(const Address &addr)
30{
31 return std::max(a: detect(s: addr.street()), b: detect(s: addr.locality()));
32}
33

source code of kcontacts/src/addressformatscript.cpp