MCPcopy Create free account
hub / github.com/davisking/dlib / convert_to_utf32

Function convert_to_utf32

dlib/unicode/unicode.h:644–715  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642
643 template <typename forward_iterator, typename unary_op>
644 inline void convert_to_utf32(
645 forward_iterator ibegin,
646 forward_iterator iend,
647 unary_op op
648 )
649 {
650
651 using char_type = std::decay_t<decltype(*ibegin)>;
652 static_assert(std::is_same<char_type, char>::value ||
653 std::is_same<char_type, wchar_t>::value ||
654 std::is_same<char_type, unichar>::value,
655 "char_type must be either char or unichar");
656
657 if (std::is_same<char_type, unichar>::value)
658 {
659 while (ibegin != iend)
660 op(*(ibegin++));
661 return;
662 }
663
664 if (std::is_same<char_type, wchar_t>::value)
665 {
666 // Unix
667 if (sizeof(wchar_t) == 4)
668 {
669 while (ibegin != iend)
670 op(static_cast<unichar>(*(ibegin++)));
671 return;
672 }
673 // Win32
674 if (sizeof(wchar_t) == 2)
675 {
676 while (ibegin != iend)
677 {
678 if (is_surrogate(*ibegin))
679 {
680 op(surrogate_pair_to_unichar(*ibegin, *(ibegin+ 1)));
681 ibegin += 2;
682 }
683 else
684 {
685 op(zero_extend_cast<unichar>(*ibegin));
686 ibegin += 1;
687 }
688 }
689 return;
690 }
691 throw invalid_utf8_error();
692 }
693
694 if (std::is_same<char_type, char>::value)
695 {
696 unichar ch;
697 int status = 0;
698 while (ibegin != iend)
699 {
700 status = unicode_helpers::u8_to_u32(ch, ibegin, iend);
701 if (status > 0)

Callers 15

get_from_clipboardFunction · 0.85
get_from_clipboardFunction · 0.85
draw_stringFunction · 0.85
set_node_labelMethod · 0.85
set_nameMethod · 0.85
set_textMethod · 0.85
on_mouse_downMethod · 0.85
on_keydownMethod · 0.85
on_string_putMethod · 0.85
set_tab_nameMethod · 0.85
set_menu_nameMethod · 0.85
draw_stringMethod · 0.85

Calls 9

is_surrogateFunction · 0.85
u8_to_u32Function · 0.85
invalid_utf8_errorClass · 0.70
reserveMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected