Skip to content

Add mbstring to KPHP (Package I & II & III -- 26 new functions)#965

Draft
catnyan02 wants to merge 32 commits intoVKCOM:masterfrom
catnyan02:mbstring
Draft

Add mbstring to KPHP (Package I & II & III -- 26 new functions)#965
catnyan02 wants to merge 32 commits intoVKCOM:masterfrom
catnyan02:mbstring

Conversation

@catnyan02
Copy link
Copy Markdown

@catnyan02 catnyan02 commented Feb 6, 2024

What is mbstring

While there are many languages in which every necessary character can be represented by a one-to-one mapping to an 8-bit value, there are also several languages which require so many characters for written communication that they cannot be contained within the range a mere byte can code (A byte is made up of eight bits. Each bit can contain only two distinct values, one or zero. Because of this, a byte can only represent 256 unique values (two to the power of eight)). Multibyte character encoding schemes were developed to express more than 256 characters in the regular bytewise coding system.

When you manipulate (trim, split, splice, etc.) strings encoded in a multibyte encoding, you need to use special functions since two or more consecutive bytes may represent a single character in such encoding schemes. Otherwise, if you apply a non-multibyte-aware string function to the string, it probably fails to detect the beginning or ending of the multibyte character and ends up with a corrupted garbage string that most likely loses its original meaning.

mbstring provides multibyte specific string functions that help you deal with multibyte encodings in PHP. In addition to that, mbstring handles character encoding conversion between the possible encoding pairs. mbstring is designed to handle Unicode-based encodings such as UTF-8 and UCS-2 and many single-byte encodings for convenience.
(source)

Installing

Similar to PHP, in KPHP mbstring is an extension, so to use mbstring in KPHP you need to specify cmake flag -DMBFL=On when building.

Runnings tests
ctest -j$(nproc) | grep mbstring
python3 kphp_tester.py mbstring

Finished

  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_strwidth
  • mb_substr_count
  • mb_substr
  • mb_substitute_character
  • mb_str_split
  • mb_list_encodings
  • mb_encoding_aliases
  • mb_preferred_mime_name
  • mb_strimwidth
  • mb_list_encodings
  • mb_strcut
  • mb_strim_width
  • mb_scrub
  • mb_regex_set_options
  • mb_ereg_match

andarut and others added 28 commits April 8, 2023 02:44
…nd Windows-1251 encodings and add runtime declarations of all mbstring functions
…r, mb_strtoupper, mb_strwidth, mb_strpos, mb_stripos, mb_strripos, mb_strrpos, mb_stristr, mb_strrchr, mb_strrichr, mb_strstr) + php tests
# Conflicts:
#	builtin-functions/_functions.txt
#	cmake/external-libraries.cmake
#	cmake/init-compilation-flags.cmake
#	compiler/compiler-settings.cpp
#	runtime/interface.cpp
#	runtime/regexp.h
#	server/server-stats.cpp
#	tests/cpp/runtime/runtime-tests.cmake
@catnyan02 catnyan02 changed the title Add mbstring to KPHP (Package I -- 14 new functions) Add mbstring to KPHP (Package I & II -- 21 new functions) May 14, 2024
@catnyan02 catnyan02 changed the title Add mbstring to KPHP (Package I & II -- 21 new functions) Add mbstring to KPHP (Package I & II & III -- 31 new functions) Jul 23, 2024
@catnyan02 catnyan02 changed the title Add mbstring to KPHP (Package I & II & III -- 31 new functions) Add mbstring to KPHP (Package I & II & III -- 26 new functions) Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants