Add mbstring to KPHP (Package I & II & III -- 26 new functions)#965
Draft
catnyan02 wants to merge 32 commits intoVKCOM:masterfrom
Draft
Add mbstring to KPHP (Package I & II & III -- 26 new functions)#965catnyan02 wants to merge 32 commits intoVKCOM:masterfrom
catnyan02 wants to merge 32 commits intoVKCOM:masterfrom
Conversation
…nd Windows-1251 encodings and add runtime declarations of all mbstring functions
add test workflow
add test workflow
…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
added 3 commits
July 18, 2024 16:08
# Conflicts: # runtime/mbstring/mbstring.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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