• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

xlnt-community / xlnt / aa719a12-330c-47b2-9460-5b2d61336ff6

03 Feb 2025 05:39PM UTC coverage: 81.978% (-1.5%) from 83.482%
aa719a12-330c-47b2-9460-5b2d61336ff6

push

circleci

web-flow
Use C++23 for generating coverage report. (#57)

Using C++23 for coverage reporting, prepares the library for coverage
testing of future post-C++11 features.

This PR makes as few changes as possible to ensure all coverage changes
are due to the changed C++/compiler version used for generating the
coverage report.

Temporarily disable warnings as errors for coverage reporting until
better C++20/23 support is added in PR #55.

11395 of 13900 relevant lines covered (81.98%)

1202684.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.17
./source/detail/unicode.cpp
1
// Copyright (c) 2014-2022 Thomas Fussell
2
// Copyright (c) 2024-2025 xlnt-community
3
//
4
// Permission is hereby granted, free of charge, to any person obtaining a copy
5
// of this software and associated documentation files (the "Software"), to deal
6
// in the Software without restriction, including without limitation the rights
7
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
// copies of the Software, and to permit persons to whom the Software is
9
// furnished to do so, subject to the following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included in
12
// all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
// THE SOFTWARE
21
//
22
// @license: http://www.opensource.org/licenses/mit-license.php
23
// @author: see AUTHORS file
24

25
#pragma clang diagnostic push
26
#pragma clang diagnostic ignored "-Wdeprecated"
27
#pragma clang diagnostic ignored "-Wweak-vtables"
28
#pragma clang diagnostic ignored "-Wsign-conversion"
29
#pragma clang diagnostic ignored "-Wsuggest-override"
30
#include <utf8.h>
31
#pragma clang diagnostic pop
32

33
#include <xlnt/utils/exceptions.hpp>
34
#include <detail/unicode.hpp>
35

36
namespace xlnt {
37
namespace detail {
38

39
std::u16string utf8_to_utf16(const std::string &utf8_string)
29✔
40
{
41
    std::u16string result;
29✔
42
    utf8::utf8to16(utf8_string.begin(), utf8_string.end(), std::back_inserter(result));
29✔
43

44
    return result;
29✔
45
}
×
46

47
std::string utf16_to_utf8(const std::u16string &utf16_string)
252✔
48
{
49
    std::string result;
252✔
50
    utf8::utf16to8(utf16_string.begin(), utf16_string.end(), std::back_inserter(result));
252✔
51

52
    return result;
252✔
53
}
×
54

55
std::string latin1_to_utf8(const std::string &latin1)
×
56
{
57
    std::string utf8;
×
58

59
    for (auto character : latin1)
×
60
    {
61
        if (character >= 0)
×
62
        {
63
            utf8.push_back(character);
×
64
        }
65
        else
66
        {
67
            utf8.push_back(static_cast<char>(0xc0 + (character >> 6)));
×
68
            utf8.push_back(static_cast<char>(0x80 + (character & 0x3f)));
×
69
        }
70
    }
71

72
    return utf8;
×
73
}
×
74

75
size_t string_length(const std::string &utf8_string)
23✔
76
{
77
    auto end_it = utf8::find_invalid(utf8_string.begin(), utf8_string.end());
23✔
78
    if (end_it != utf8_string.end())
23✔
79
    {
80
        throw xlnt::exception("Invalid UTF-8 encoding detected");
3✔
81
    }
82

83
    return static_cast<std::size_t>(utf8::distance(utf8_string.begin(), end_it));
44✔
84
}
85

86
} // namespace detail
87
} // namespace xlnt
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc