-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrb_u_string_normalized.c
More file actions
28 lines (25 loc) · 960 Bytes
/
rb_u_string_normalized.c
File metadata and controls
28 lines (25 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "rb_includes.h"
/* @overload normalize?(mode = :default)
*
* Returns true if it can be determined that the receiver is normalized
* according to MODE.
*
* See {#normalize} for a discussion on normalization and a list of the
* possible normalization modes.
*
* @param [#to_sym] mode
* @return [Boolean]
* @see http://unicode.org/reports/tr15/
* Unicode Standard Annex #15: Unicode Normalization Forms */
VALUE
rb_u_string_normalized(int argc, VALUE *argv, VALUE self)
{
const struct rb_u_string *string = RVAL2USTRING(self);
VALUE rbform;
enum u_normalization_form form = U_NORMALIZATION_FORM_D;
if (rb_scan_args(argc, argv, "01", &rbform) == 1)
form = _rb_u_symbol_to_normalization_form(rbform);
return u_normalized(USTRING_STR(string),
USTRING_LENGTH(string),
form) == U_NORMALIZED_YES ? Qtrue : Qfalse;
}