Module: IDN::Stringprep

Defined in:
ext/stringprep.c

Class Method Summary collapse

Class Method Details

.IDN::Stringprep.nameprep(string) ⇒ String

Prepares a string in UTF-8 format according to the ‘Nameprep’ profile.

Raises IDN::Stringprep::StringprepError on failure.

Returns:

  • (String)


89
90
91
92
# File 'ext/stringprep.c', line 89

static VALUE nameprep(VALUE self, VALUE str)
{
  return stringprep_internal(str, "Nameprep");
}

.IDN::Stringprep.nfkc_normalize(string) ⇒ String

Converts a string in UTF-8 format into canonical form, standardizing such issues as whether a character with an accent is represented as a base character and combining accent or as a single precomposed character.

Returns:

  • (String)


150
151
152
153
154
155
156
157
158
159
160
161
# File 'ext/stringprep.c', line 150

static VALUE nfkc_normalize(VALUE self, VALUE str)
{
  char *buf;
  VALUE retv;

  str = rb_check_convert_type(str, T_STRING, "String", "to_s");
  buf = stringprep_utf8_nfkc_normalize(RSTRING(str)->ptr, RSTRING(str)->len);

  retv = rb_str_new2(buf);
  xfree(buf);
  return retv;
}

.IDN::Stringprep.nodeprep(string) ⇒ String

Prepares a string in UTF-8 format according to the ‘Nodeprep’ profile.

Raises IDN::Stringprep::StringprepError on failure.

Returns:

  • (String)


104
105
106
107
# File 'ext/stringprep.c', line 104

static VALUE nodeprep(VALUE self, VALUE str)
{
  return stringprep_internal(str, "Nodeprep");
}

.IDN::Stringprep.resourceprep(string) ⇒ String

Prepares a string in UTF-8 format according to the ‘Resourceprep’ profile.

Raises IDN::Stringprep::StringprepError on failure.

Returns:

  • (String)


119
120
121
122
# File 'ext/stringprep.c', line 119

static VALUE resourceprep(VALUE self, VALUE str)
{
  return stringprep_internal(str, "Resourceprep");
}

.IDN::Stringprep.with_profile(string, profile) ⇒ String

Prepares a string in UTF-8 format according to the given stringprep profile name which must be one of the internally supported stringprep profiles (for details see IANA’s Profile Names in RFC3454).

Raises IDN::Stringprep::StringprepError on failure.

Returns:

  • (String)


135
136
137
138
139
# File 'ext/stringprep.c', line 135

static VALUE with_profile(VALUE self, VALUE str, VALUE profile)
{
  profile = rb_check_convert_type(profile, T_STRING, "String", "to_s");
  return stringprep_internal(str, RSTRING(profile)->ptr);
}