1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* |
4 |
|
|
* This program and the accompanying materials are made available under the |
5 |
|
|
* terms of the MIT License which is available at |
6 |
|
|
* https://opensource.org/licenses/MIT. |
7 |
|
|
* |
8 |
|
|
* SPDX-License-Identifier: MIT |
9 |
|
|
**************************************************************************/ |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
/**************************************************************************/ |
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/** */ |
15 |
|
|
/** GUIX Component */ |
16 |
|
|
/** */ |
17 |
|
|
/** Utility (Utility) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
/* Include necessary system files. */ |
24 |
|
|
|
25 |
|
|
#include "gx_api.h" |
26 |
|
|
#include "gx_utility.h" |
27 |
|
|
|
28 |
|
|
/**************************************************************************/ |
29 |
|
|
/* */ |
30 |
|
|
/* FUNCTION RELEASE */ |
31 |
|
|
/* */ |
32 |
|
|
/* _gx_utility_utf8_string_backward_character_length_get */ |
33 |
|
|
/* PORTABLE C */ |
34 |
|
|
/* 6.1 */ |
35 |
|
|
/* AUTHOR */ |
36 |
|
|
/* */ |
37 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
38 |
|
|
/* */ |
39 |
|
|
/* DESCRIPTION */ |
40 |
|
|
/* */ |
41 |
|
|
/* This function returns the glyph length of the previous character */ |
42 |
|
|
/* from the specified byte position. */ |
43 |
|
|
/* */ |
44 |
|
|
/* INPUT */ |
45 |
|
|
/* */ |
46 |
|
|
/* string UTF-8 string */ |
47 |
|
|
/* start_index Specified byte position */ |
48 |
|
|
/* glyph_len Length of glyph value in byte */ |
49 |
|
|
/* */ |
50 |
|
|
/* OUTPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* status Completion status */ |
53 |
|
|
/* */ |
54 |
|
|
/* CALLS */ |
55 |
|
|
/* */ |
56 |
|
|
/* */ |
57 |
|
|
/* CALLED BY */ |
58 |
|
|
/* */ |
59 |
|
|
/* GUIX Internal Code */ |
60 |
|
|
/* */ |
61 |
|
|
/* RELEASE HISTORY */ |
62 |
|
|
/* */ |
63 |
|
|
/* DATE NAME DESCRIPTION */ |
64 |
|
|
/* */ |
65 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
66 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
67 |
|
|
/* resulting in version 6.1 */ |
68 |
|
|
/* */ |
69 |
|
|
/**************************************************************************/ |
70 |
|
|
#ifdef GX_UTF8_SUPPORT |
71 |
|
2812 |
UINT _gx_utility_utf8_string_backward_character_length_get(GX_STRING *string, INT start_index, UINT *glyph_len) |
72 |
|
|
{ |
73 |
|
2812 |
UINT len = 0; |
74 |
|
|
|
75 |
|
|
/* Get glyph lengh of the character in backward direction. */ |
76 |
✓✓ |
3959 |
while (start_index >= 0) |
77 |
|
|
{ |
78 |
|
3958 |
len++; |
79 |
|
|
|
80 |
✓✓ |
3958 |
if (((string -> gx_string_ptr[start_index] & 0x80) == 0) || |
81 |
✓✓ |
1720 |
((string -> gx_string_ptr[start_index] & 0xC0) == 0xC0)) |
82 |
|
|
{ |
83 |
|
|
/* End loop when byte match 0xxxxxxx or 11xxxxxx. */ |
84 |
|
|
break; |
85 |
|
|
} |
86 |
|
|
|
87 |
|
1147 |
start_index--; |
88 |
|
|
} |
89 |
|
|
|
90 |
|
2812 |
*glyph_len = len; |
91 |
|
|
|
92 |
|
2812 |
return GX_SUCCESS; |
93 |
|
|
} |
94 |
|
|
#endif /* GX_UTF8_SUPPORT */ |
95 |
|
|
|