#endif
#ifndef _di_f_utf_is_bom_
- f_return_status f_utf_is_bom(const f_string character, const f_u_short maxWidth) {
+ f_return_status f_utf_is_bom(const f_string character, const f_u_short max_width) {
#ifndef _di_level_0_parameter_checking_
- if (maxWidth < 1) return f_error_set_error(f_invalid_parameter);
+ if (max_width < 1) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
f_u_short width = f_macro_utf_byte_width(*character);
return f_false;
}
- if (width > maxWidth) {
+ if (width > max_width) {
return f_error_set_error(f_maybe);
}
#endif // _di_f_utf_is_bom_
#ifndef _di_f_utf_is_space_
- f_return_status f_utf_is_space(const f_string character, const f_u_short maxWidth) {
+ f_return_status f_utf_is_space(const f_string character, const f_u_short max_width) {
#ifndef _di_level_0_parameter_checking_
- if (maxWidth < 1) return f_error_set_error(f_invalid_parameter);
+ if (max_width < 1) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
f_u_short width = f_macro_utf_byte_width(*character);
return f_false;
}
- if (width > maxWidth) {
+ if (width > max_width) {
return f_error_set_error(f_maybe);
}
return f_true;
}
- if (!memcmp(character, f_utf_bom, width)) {
- return f_true;
- }
-
return f_false;
}
#endif // _di_f_utf_is_space_
#ifndef _di_f_utf_is_substitute_
- f_return_status f_utf_is_substitute(const f_string character, const f_u_short maxWidth) {
+ f_return_status f_utf_is_substitute(const f_string character, const f_u_short max_width) {
#ifndef _di_level_0_parameter_checking_
- if (maxWidth < 1) return f_error_set_error(f_invalid_parameter);
+ if (max_width < 1) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
f_u_short width = f_macro_utf_byte_width(*character);
return f_false;
}
- if (width > maxWidth) {
+ if (width > max_width) {
return f_error_set_error(f_maybe);
}
#endif // _di_f_utf_is_substitute_
#ifndef _di_f_utf_is_whitespace_
- f_return_status f_utf_is_whitespace(const f_string character, const f_u_short maxWidth) {
+ f_return_status f_utf_is_whitespace(const f_string character, const f_u_short max_width) {
#ifndef _di_level_0_parameter_checking_
- if (maxWidth < 1) return f_error_set_error(f_invalid_parameter);
+ if (max_width < 1) return f_error_set_error(f_invalid_parameter);
#endif // _di_level_0_parameter_checking_
f_u_short width = f_macro_utf_byte_width(*character);
return f_false;
}
- if (width > maxWidth) {
+ if (width > max_width) {
return f_error_set_error(f_maybe);
}
* The f_macro_utf_byte_is_* macros are used to determine a width of the character (either 1, 2, 3, or 4, respectively).
*
* The f_macro_utf_byte_width macro determines a width of the character.
+ *
+ * The f_macro_utf_byte_width_is is identical to f_macro_utf_byte_width, except it returns 0 when character is not UTF-8.
*/
#ifndef _di_f_utf_byte_
#define f_utf_byte_1 0x80 // 1000 0000
#define f_macro_utf_byte_is_3(character) ((character & f_utf_byte_off_3) == f_utf_byte_3) // (1110 xxxx & 1111 0000) == 1110 0000
#define f_macro_utf_byte_is_4(character) ((character & f_utf_byte_off_4) == f_utf_byte_4) // (1111 0xxx & 1111 1000) == 1111 0000
- #define f_macro_utf_byte_width(character) (!f_macro_utf_byte_is(character) || f_macro_utf_byte_is_1(character)) ? 1 : (f_macro_utf_byte_is_2(character) ? 2 : (f_macro_utf_byte_is_3(character) ? 3 : 4))
+ #define f_macro_utf_byte_width(character) (!f_macro_utf_byte_is(character) || f_macro_utf_byte_is_1(character)) ? 1 : (f_macro_utf_byte_is_2(character) ? 2 : (f_macro_utf_byte_is_3(character) ? 3 : 4))
+ #define f_macro_utf_byte_width_is(character) (f_macro_utf_byte_is(character) ? (f_macro_utf_byte_is_1(character) ? 1 : (f_macro_utf_byte_is_2(character) ? 2 : (f_macro_utf_byte_is_3(character) ? 3 : 4))) : 0)
#endif // _di_f_utf_byte_
/**
*
* @param character
* The character to validate.
- * There must be enough space allocated to compare against, as limited by maxWidth.
- * @param maxWidth
+ * There must be enough space allocated to compare against, as limited by max_width.
+ * @param max_width
* The maximum width available for checking.
* Can be anything greater than 0.
*
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_f_utf_is_bom_
- extern f_return_status f_utf_is_bom(const f_string character, const f_u_short maxWidth);
+ extern f_return_status f_utf_is_bom(const f_string character, const f_u_short max_width);
#endif // _di_f_utf_is_bom_
/**
* Check to see if the entire byte block of the character is a UTF-8 whitespace or substitute character.
*
- * This will also return TRUE for the UTF-8 BOM.
- *
* This does not check non-UTF-8 whitespace.
*
* @param character
* The character to validate.
- * There must be enough space allocated to compare against, as limited by maxWidth.
- * @param maxWidth
+ * There must be enough space allocated to compare against, as limited by max_width.
+ * @param max_width
* The maximum width available for checking.
* Can be anything greater than 0.
*
* @return
- * f_true if a UTF-8 whitespace, substitute, or UTF-8 BOM.
+ * f_true if a UTF-8 whitespace or substitute.
* f_false if not a UTF-8 whitespace or substitute.
* f_maybe (with error bit) if this could be a whitespace or substitute but width is not long enough.
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_f_utf_is_space_
- extern f_return_status f_utf_is_space(const f_string character, const f_u_short maxWidth);
+ extern f_return_status f_utf_is_space(const f_string character, const f_u_short max_width);
#endif // _di_f_utf_is_space_
/**
*
* @param character
* The character to validate.
- * There must be enough space allocated to compare against, as limited by maxWidth.
- * @param maxWidth
+ * There must be enough space allocated to compare against, as limited by max_width.
+ * @param max_width
* The maximum width available for checking.
* Can be anything greater than 0.
*
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_f_utf_is_substitute_
- extern f_return_status f_utf_is_substitute(const f_string character, const f_u_short maxWidth);
+ extern f_return_status f_utf_is_substitute(const f_string character, const f_u_short max_width);
#endif // _di_f_utf_is_substitute_
/**
*
* @param character
* The character to validate.
- * There must be enough space allocated to compare against, as limited by maxWidth.
- * @param maxWidth
+ * There must be enough space allocated to compare against, as limited by max_width.
+ * @param max_width
* The maximum width available for checking.
* Can be anything greater than 0.
*
* f_invalid_parameter (with error bit) if a parameter is invalid.
*/
#ifndef _di_f_utf_is_whitespace_
- extern f_return_status f_utf_is_whitespace(const f_string character, const f_u_short maxWidth);
+ extern f_return_status f_utf_is_whitespace(const f_string character, const f_u_short max_width);
#endif // _di_f_utf_is_whitespace_
#ifdef __cplusplus