{"id":350665,"date":"2023-07-23T15:00:40","date_gmt":"2023-07-23T15:00:40","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350665"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350665","title":{"rendered":"<span>\u041a\u0430\u043a \u0434\u0432\u0430 \u0431\u0430\u0439\u0442\u0430 \u043f\u0435\u0440\u0435\u0441\u043b\u0430\u0442\u044c: \u043a\u043e\u043d\u0442\u0440\u0438\u0431\u044c\u044e\u0442\u0438\u043c \u0432 KPHP<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 KPHP<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cf2\/d1a\/cba\/cf2d1acba5bd8c3341d9e1c47ac3f2b3.png\" alt=\"kphp-1\" width=\"680\" height=\"187\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cf2\/d1a\/cba\/cf2d1acba5bd8c3341d9e1c47ac3f2b3.png\"\/><\/p>\n<div><figcaption>kphp-1<\/figcaption><\/div>\n<\/figure>\n<p>KPHP &#8212; \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u043b\u044f PHP. \u041e\u043d \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 PHP \u043a\u043e\u0434 \u0432 \u043a\u043e\u0434 \u043d\u0430 C++, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0440\u0430\u0437. \u042d\u0442\u043e open-source \u043f\u0440\u043e\u0435\u043a\u0442, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \u043d\u0430 9 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0441\u0442\u0440\u043e\u043a PHP \u043a\u043e\u0434\u0430 \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435.<\/p>\n<h3>\u0426\u0435\u043b\u044c<\/h3>\n<p>\u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 runtime KPHP. \u0422\u043e\u0447\u043d\u0435\u0435 \u043f\u0440\u043e \u0442\u0435\u0440\u043d\u0438\u0441\u0442\u0443\u044e \u0434\u043e\u0440\u043e\u0433\u0443 \u043d\u0430 \u043f\u0443\u0442\u0438.<\/p>\n<h3>\u041f\u043b\u0430\u043d<\/h3>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/p>\n<\/li>\n<li>\n<p>runtime <\/p>\n<ul>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0442\u0438\u043f\u044b<\/p>\n<\/li>\n<li>\n<p>\u0444\u043b\u0430\u0433\u0438<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0422\u0435\u0441\u0442\u044b <\/p>\n<ul>\n<li>\n<p>cpp \u0442\u0435\u0441\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>php \u0442\u0435\u0441\u0442\u044b<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>pull_request<\/p>\n<\/li>\n<\/ol>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h3>\n<p><a href=\"https:\/\/vkcom.github.io\/kphp\/kphp-internals\/developing-and-extending-kphp\/compiling-kphp-from-sources.html\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c kphp \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a><\/p>\n<h3>runtime<\/h3>\n<h4>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h4>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>mb_check_encoding<\/code> \u0438\u0437 php. \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0438\u0434\u0435\u043c \u0432 \u0434\u043e\u043a\u0438: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ff\/ea0\/5df\/1ffea05df5db38c67c88ee98c55389f8.png\" alt=\"\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 01 39 38\" width=\"1058\" height=\"345\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ff\/ea0\/5df\/1ffea05df5db38c67c88ee98c55389f8.png\"\/><\/p>\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 01 39 38<\/figcaption><\/div>\n<\/figure>\n<p>\u0423\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0442\u0440\u043e\u043a. \u041c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0434\u0435\u043c \u0432 <a href=\"https:\/\/github.com\/php\/php-src\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434 php<\/a> \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 php: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1c6\/764\/3cc\/1c67643cc10fe32cfa67f0bc0c1c4375.png\" alt=\"\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 01 51 49\" width=\"881\" height=\"522\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1c6\/764\/3cc\/1c67643cc10fe32cfa67f0bc0c1c4375.png\"\/><\/p>\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 01 51 49<\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0438\u0448\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0442\u0440\u0435\u0439\u0441\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cf9\/f80\/e75\/cf9f80e754a8015d438d3d9d5271a826.png\" alt=\"\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 01 55 59\" width=\"888\" height=\"675\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cf9\/f80\/e75\/cf9f80e754a8015d438d3d9d5271a826.png\"\/><\/p>\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 01 55 59<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0438\u0434\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 <code>mbfl_encoding<\/code>. \u0418\u0449\u0435\u043c: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eef\/1cc\/d5d\/eef1ccd5d9d051e46373085be89b9183.png\" alt=\"\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 02 12 42\" width=\"794\" height=\"458\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eef\/1cc\/d5d\/eef1ccd5d9d051e46373085be89b9183.png\"\/><\/p>\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 02 12 42<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 &#8212; \u0447\u0430\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>libmbfl<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0438\u0434\u0438\u043c\u043e \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0435\u0439. \u0418\u0449\u0435\u043c \u0435\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d33\/12f\/9fb\/d3312f9fb2e44e4d19f3dff364bdbeea.png\" alt=\"\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 02 10 43\" width=\"1598\" height=\"885\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d33\/12f\/9fb\/d3312f9fb2e44e4d19f3dff364bdbeea.png\"\/><\/p>\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 02 10 43<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u044c\u043c\u0435\u0442 \u0432\u0441\u044e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u043d\u0430 \u0441\u0435\u0431\u044f, \u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u044d\u0442\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c, \u0438\u0437\u0443\u0447\u0430\u0435\u043c \u0435\u0435 \u0438 \u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u0438\u0448\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0438\u043a\u0435 (\u043d\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 kphp, \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u043c \u043d\u0430\u0434\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e). \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0443\u0436\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 <code>mb_convert_encoding<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0442\u043e\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c:<\/p>\n<pre><code class=\"cpp\">#include &lt;libmbfl\/mbfl\/mbfilter.h>  mbfl_string *mb_convert_encoding(const char *str, const char *to, const char *from) {  int len = strlen(str); enum mbfl_no_encoding from_encoding, to_encoding; mbfl_buffer_converter *convd = NULL; mbfl_string _string, result, *ret;  \/* from internal to mbfl *\/ from_encoding = mbfl_name2no_encoding(from); to_encoding = mbfl_name2no_encoding(to);  \/* init buffer mbfl strings *\/ mbfl_string_init(&amp;_string); mbfl_string_init(&amp;result); _string.no_encoding = from_encoding; _string.len = len; _string.val = (unsigned char*)str;  \/* converting *\/ convd = mbfl_buffer_converter_new(from_encoding, to_encoding, 0); ret = mbfl_buffer_converter_feed_result(convd, &amp;_string, &amp;result); mbfl_buffer_converter_delete(convd);  \/* fix converting with multibyte encodings *\/ if (len % 2 != 0 &amp;&amp; ret->len % 2 == 0 &amp;&amp; len &lt; ret->len) { ret->len++; ret->val[ret->len-1] = 63; }  return ret; }  bool mb_check_encoding(const char *value, const char *encoding) {  \/* init buffer mbfl strins *\/ mbfl_string _string; mbfl_string_init(&amp;_string); _string.val = (unsigned char*)value; _string.len = strlen((char*)value);  \/* from internal to mbfl *\/ const mbfl_encoding *enc = mbfl_name2encoding(encoding);  \/* get all supported encodings *\/ const mbfl_encoding **encs = mbfl_get_supported_encodings(); int len = sizeof(**encs);  \/* identify encoding of input string *\/ \/* Warning! String can be represented in different encodings, so check needed *\/ const mbfl_encoding *i_enc = mbfl_identify_encoding2(&amp;_string, encs, len, 1);  \/* perform convering *\/ const char *i_enc_str = (const char*)mb_convert_encoding(value, i_enc->name, enc->name)->val; const char *enc_str = (const char*)mb_convert_encoding(i_enc_str, enc->name, i_enc->name)->val;  \/* check equality *\/ \/* Warning! strcmp not working, because of different encodings *\/ bool res = true; for (int i = 0; i &lt; strlen(enc_str); i++) if (enc_str[i] != value[i]) { res = false; break; }  free((void*)i_enc_str); free((void*)enc_str); return res; } <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0438\u0448\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 runtime kphp. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c 4 \u0448\u0430\u0433\u0430:<\/p>\n<ol>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c php-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (txt)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c (h)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 (cpp)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u0441\u0431\u043e\u0440\u043a\u0443 (cmake)<\/p>\n<\/li>\n<\/ol>\n<h3>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c php-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (txt)<\/h3>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 php \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e \u0442\u0438\u043f\u044b \u0432 kphp <a href=\"https:\/\/vkcom.github.io\/kphp\/kphp-language\/static-type-system\/kphp-type-system.html\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a> <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/843\/d34\/ddc\/843d34ddce463da220aca65033b63272.png\" alt=\"kphp-types\" width=\"1582\" height=\"1218\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/843\/d34\/ddc\/843d34ddce463da220aca65033b63272.png\"\/><\/p>\n<div><figcaption>kphp-types<\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u0442\u0430\u043a, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b <code>builtin-functions\/_functions.txt<\/code>. \u0418 \u0432 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u043d\u0435\u0446 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438\u0437 php. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 php mb_check_encoding \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"php\">function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool<\/code><\/pre>\n<p>\u0432 kphp \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442:<\/p>\n<pre><code class=\"php\">function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool;<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f mb_convert_encoding \u0432 php:<\/p>\n<pre><code class=\"php\">function mb_convert_encoding(array|string $string, string $to_encoding, array|string|null $from_encoding = null): array|string|false<\/code><\/pre>\n<p>\u0432 kphp:<\/p>\n<pre><code class=\"php\">function mb_convert_encoding(array|string $string, string $to_encoding, array|string|null $from_encoding = null): array|string|false;<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434.<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c (h)<\/h3>\n<p>\u0412\u0441\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 <code>runtime<\/code>. \u041d\u0430\u0448\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f <code>mbstring<\/code> \u0434\u043b\u044f php. \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b\u0438\u043a <code>mbstring.h<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dfa\/aa4\/640\/dfaaa46404faa45cda23d78de926dfed.png\" alt=\"\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 23 27 45\" width=\"1219\" height=\"522\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dfa\/aa4\/640\/dfaaa46404faa45cda23d78de926dfed.png\"\/><\/p>\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 23 27 45<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f mb_check_encoding \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430, \u0441\u0442\u0440\u0430\u043d\u043d\u043e. \u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <code>f$<\/code>? \u0422\u0430\u043a kphp \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u0435 \u043a\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 <code>builtin-functions\/_functions.txt<\/code>. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c cpp \u0444\u0430\u0439\u043b: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bf4\/4a7\/19f\/bf44a719f61573871064eb7f3996a1ea.png\" alt=\"\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 22 25 11\" width=\"827\" height=\"269\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bf4\/4a7\/19f\/bf44a719f61573871064eb7f3996a1ea.png\"\/><\/p>\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 22 25 11<\/figcaption><\/div>\n<\/figure>\n<p>\u0425\u043c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430, \u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043e\u043a (UTF-8 \u0438 Windows-1251). \u041d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u0438\u043c \u0432\u0441\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438! (\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u0445 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432 \u043a\u043e\u043d\u0446\u0435). \u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u0430 <code>string<\/code>. \u041b\u043e\u0432\u0443\u0448\u043a\u0430! \u042d\u0442\u043e \u043d\u0435 string \u0438\u0437 I\/O! \u042d\u0442\u043e string \u0438\u0437 kphp! \u0413\u0434\u0435 \u043f\u0440\u043e \u043d\u0435\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c? \u0412\u0441\u0435 \u0442\u0438\u043f\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0438\u0437 <code>runtime\/kphp_core.h<\/code>. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043d\u0443\u0442\u0440\u0438: <img inline=\"true\" class=\"image image-inline\" width=\"552\" height=\"340\"\/>. \u041f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>mb_check_encoding<\/code>:<\/p>\n<pre><code class=\"cpp\">bool f$mb_check_encoding(const string &amp;value, const string &amp;encoding);<\/code><\/pre>\n<p>\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f <code>mb_convert_encoding<\/code>:<\/p>\n<pre><code class=\"cpp\">string f$mb_convert_encoding(const string &amp;str, const string &amp;to_encoding, const string &amp;from_encoding);<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0438\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 (cpp)<\/h3>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0432\u0441\u0435 \u0442\u0438\u043f\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <code>string.inl<\/code> \u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u0438\u0437 \u043d\u0435\u0435 <code>const char *<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0438\u043b\u0438 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c string \u0438\u0437 <code>const char *<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>mb_check_encoding<\/code>:<\/p>\n<pre><code class=\"cpp\">bool f$mb_check_encoding(const string &amp;value, const string &amp;encoding) { const char *c_encoding = encoding.c_str(); const char *c_value = value.c_str(); \/\/ ... }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>mb_convert_encoding<\/code>:<\/p>\n<pre><code class=\"cpp\">string f$mb_convert_encoding(const string &amp;str, const string &amp;to_encoding, const string &amp;from_encoding) { const char *c_string = s.c_str(); const char *c_to_encoding = to_encoding.c_str(); const char *c_from_encoding = from_encoding.c_str(); \/\/ ... return string((const char*)ret->val, ret->len); }<\/code><\/pre>\n<h3>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u0441\u0431\u043e\u0440\u043a\u0443 (cmake)<\/h3>\n<p>\u0418\u0434\u0435\u043c \u0432 <code>runtime\/runtime.cmake<\/code>. \u0412\u0441\u0435 cpp \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0432 <code>KPHP_RUNTIME_SOURCES<\/code>. \u041d\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>mbstring.cpp<\/code> \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432 \u0441\u0431\u043e\u0440\u043a\u0443. \u041d\u043e, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443:<\/p>\n<pre><code class=\"cmake\">prepend(KPHP_RUNTIME_MBSTRING_SOURCES         mbstring.cpp)<\/code><\/pre>\n<p>\u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432 <code>KPHP_RUNTIME_SOURCES<\/code> \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>mbstring.cpp<\/code>, \u0430 <code>KPHP_RUNTIME_MBSTRING_SOURCES<\/code>:<\/p>\n<pre><code class=\"cmake\">prepend(KPHP_RUNTIME_SOURCES ${BASE_DIR}\/runtime\/         ${KPHP_RUNTIME_MBSTRING_SOURCES} ...<\/code><\/pre>\n<p>\u0424\u0443\u0445, \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u043e\u0447\u043d\u043e \u0432\u0441\u0435. \u0411\u0438\u043b\u0434\u0438\u043c!<\/p>\n<pre><code>mkdir build &amp;&amp; cd build &amp;&amp; cmake .. -DDOWNNLOAD_MISSING_LIBRARIES=On &amp;&amp; make -j$(nproc)<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c test.php:<\/p>\n<pre><code class=\"php\">echo mb_check_encoding(\"Hello World\", \"UTF-8\");<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c!<\/p>\n<pre><code>.\/objs\/bin\/kphp2cpp -M test.php &amp;&amp; .\/kphp_out\/cli<\/code><\/pre>\n<p>\u0423\u0440\u0430! \u041c\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c kphp!<\/p>\n<h4>!!! \u0412\u0430\u0436\u043d\u043e !!!<\/h4>\n<p>\u041d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u041c\u044b \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 (\u043b\u0438\u0448\u044c \u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e). \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<ol>\n<li>\n<p>\u0418 \u0431\u044b\u043b\u043e \u0431\u044b \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0442\u043e\u043d\u043e\u043c \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0435\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 php. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 php <code>mb_convert_encoding<\/code> \u0435\u0441\u043b\u0438 \u043f\u0440\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0435, \u0442\u043e \u0438\u0445 \u0431\u0430\u0439\u0442\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 0x63 (&#8216;?&#8217; \u0432 ASCII). \u042d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 <code>f$<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b &#8212; <code>mb_check_en\u0441oding<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a \u0438\u043b\u0438 <code>null<\/code>, \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c. \u041f\u0440\u0438\u0447\u0435\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e php (\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 php \u043d\u0435\u043b\u043e\u0433\u0438\u0447\u043d\u043e). \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f <code>mb_convert_encoding<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<\/li>\n<li>\n<p><code>mbstring<\/code> \u044d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 kphp, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 <code>php-src<\/code>, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u043b\u0430\u0433 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u044d\u0442\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 php.<\/p>\n<\/li>\n<\/ol>\n<h4>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0442\u043e\u043d<\/h4>\n<ol>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>const &amp;<\/code> \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f)<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u0432 php (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>static<\/code>):<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">static bool check_en\u0441oding(const char *value, const char *encoding) { \/\/ ... }  bool f$mb_check_encoding(const string &amp;value, const string &amp;encoding) { const char *c_encoding = encoding.c_str(); const char *c_value = value.c_str(); bool res = check_en\u0441oding(c_value, c_encoding); \/\/ process differences in php return res }<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>noexcept<\/code> \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">static bool check_en\u0441oding(const char *value, const char *encoding) { \/\/ ... }  bool f$mb_check_encoding(const string &amp;value, const string &amp;encoding) noexcept { const char *c_encoding = encoding.c_str(); const char *c_value = value.c_str(); bool res = check_en\u0441oding(c_value, c_encoding); \/\/ process differences in php return res }<\/code><\/pre>\n<h4>\u0422\u0438\u043f\u044b<\/h4>\n<p><code>mb_check_encoding<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c <code>string|array|null<\/code> (\u0441\u0443\u0434\u044f \u043f\u043e php-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443). \u0412 C++ \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0442\u0430\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0438\u043f \u043d\u0430 <code>mixed<\/code> (\u0441\u043c\u0435\u0448\u0430\u043d\u043d\u044b\u0439). \u041f\u0440\u043e <code>mixed<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u0438\u043f\u0443 <code>string<\/code>. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 <code>mb_check_encoding<\/code> (\u0441\u0443\u0434\u044f \u043f\u043e php-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443) \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>?string<\/code>, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <code>Optional&lt;string><\/code>. \u041f\u0440\u043e <code>Optional<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u0438\u043f\u0443 <code>string<\/code>. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>mixed<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f \u0447\u0435\u0440\u0435\u0437 <code>.is_&lt;\u0442\u0438\u043f><\/code> \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u0442\u0438\u043f\u0443 \u0447\u0435\u0440\u0435\u0437 <code>.to_&lt;\u0442\u0438\u043f><\/code>. \u0418\u0437 <code>Optional<\/code> \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 <code>.val()<\/code>.<\/p>\n<pre><code class=\"cpp\">static bool check_en\u0441oding(const char *value, const char *encoding) { \/\/ ... }  bool f$mb_check_encoding(const mixed &amp;value, const Optional&lt;string> &amp;encoding) noexcept { if (encoding.is_null() || value.is_null()) return 1; const char *c_encoding = encoding.val().c_str(); if (value.is_string()) { \/\/ ... } if (value.is_array()) { \/\/ ... } return 1; }<\/code><\/pre>\n<h4>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435<\/h4>\n<p><code>mbstring<\/code> \u044d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 php, \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u0444\u043b\u0430\u0433 \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0441 <code>cmake<\/code>. \u041f\u0443\u0441\u0442\u044c \u0444\u043b\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 &#8212; <code>MBFL<\/code> \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u043e 3 \u0448\u0430\u0433\u0430:<\/p>\n<ol>\n<li>\n<p><code>cmake\/external-libraries.cmake<\/code> &#8212; \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u043b\u0430\u0433 \u0432 cmake \u0438 \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cmake\">option(DOWNLOAD_MISSING_LIBRARIES \"download and build missing libraries if needed\" OFF) option(MBFL \"build mbstring\" OFF) # ...<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p><code>runtime\/runtime.cmake<\/code> &#8212; \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u043e \u0444\u043b\u0430\u0433\u0443<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cmake\"># ... if (MBFL) prepend(KPHP_RUNTIME_MBSTRING_SOURCES mbstring.cpp) endif() # ... prepend(KPHP_RUNTIME_SOURCES ${BASE_DIR}\/runtime\/         ${KPHP_RUNTIME_MBSTRING_SOURCES} # ...<\/code><\/pre>\n<p>\u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 <code>mbstring.cpp<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0432 \u0441\u0430\u043c\u043e\u043c kphp (\u043d\u0435 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435). \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c <code>mbstring.cpp<\/code>, \u043d\u043e \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u0444\u043b\u0430\u0433\u0443. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e 3 \u0448\u0430\u0433\u0430:<\/p>\n<ol>\n<li>\n<p><code>cmake\/external-libraries.cmake<\/code> &#8212; \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u043b\u0430\u0433 \u0432 cmake \u0438 \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cmake\">option(DOWNLOAD_MISSING_LIBRARIES \"download and build missing libraries if needed\" OFF) option(MBFL \"build mbstring\" OFF) # ...<\/code><\/pre>\n<ol start=\"2\">\n<li>\n<p><code>compiler\/compiler-settings.cpp<\/code> &#8212; \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0444\u043b\u0430\u0433 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438\u0437 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">void CompilerSettings::init() { \/\/ ... std::stringstream ss; #ifdef MBFL ss &lt;&lt; \" -DMBFL \"; #endif \/\/ ...<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p><code>runtime\/mbstring.*<\/code> &#8212; \u0447\u0435\u0440\u0435\u0437 <code>#ifdef<\/code> \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0444\u043b\u0430\u0433 \u0438\u0437 cmake:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">#ifdef MBFL bool f$mb_check_encoding(const mixed &amp;value, const Optional&lt;string> &amp;encoding) noexcept; #endif <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c:<\/p>\n<pre><code>cmake .. -DMBFL=On<\/code><\/pre>\n<h4>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 php<\/h4>\n<p>\u0412 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435&#8230;<\/p>\n<h4>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/h4>\n<p>\u0412\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043b\u0438\u043d\u043a\u0443\u0435\u0442\u0441\u044f. \u041d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0445\u043e\u0440\u043e\u0448\u043e, \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0435\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b kphp \u043f\u043e \u0444\u043b\u0430\u0433\u0443 <code>MBFL<\/code> \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0441\u043e\u0431\u0438\u0440\u0430\u043b \u0438 \u043b\u0438\u043d\u043a\u043e\u0432\u0430\u043b. \u0422\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0434\u043e\u043a\u0438 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 + \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u043e\u0440\u043e\u0437\u0438\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430 \u0444\u043e\u0440\u043a\u0435. \u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c <a href=\"https:\/\/github.com\/andreylzmw\/libmbfl\/commit\/ed66e4e03afb7cc85385974c00542505be4556e8\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0439 \u0444\u043e\u0440\u043a<\/a> <code>libmbfl<\/code>. \u041c\u043d\u0435 \u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439, \u043e\u043d\u0430 \u0441 1992 \u0433\u043e\u0434\u0430 \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043d\u0435\u0442 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043d\u0435\u0442 \u0441\u0442\u0430\u0442\u0435\u0439 \u0441 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u043d\u0435\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043a \u043a\u043e\u0434\u0443 \u0438 \u0431\u0438\u043b\u0434\u0438\u0442\u0441\u044f \u043e\u043d\u0430 \u043f\u043e-\u0441\u0432\u043e\u0435\u043c\u0443. \u0427\u0442\u043e\u0431\u044b kphp \u0441\u0430\u043c \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043b, \u0431\u0438\u043b\u0434\u0438\u043b \u0438 \u043b\u0438\u043d\u043a\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0448\u0430\u0433\u043e\u0432:<\/p>\n<ol>\n<li>\n<p>\u0423\u0431\u0440\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 &#8216;\u043f\u043e-\u0441\u0432\u043e\u0435\u043c\u0443&#8217;<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0440\u0433\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0449\u0435\u0442 kphp<\/p>\n<\/li>\n<li>\n<p>\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u043b\u0438\u043d\u043a\u043e\u0432\u043a\u0443 \u0432 <code>cmake<\/code><\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 \u0438\u043c\u043f\u043e\u0440\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430<\/p>\n<\/li>\n<\/ol>\n<h3>\u0423\u0431\u0440\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 &#8216;\u043f\u043e-\u0441\u0432\u043e\u0435\u043c\u0443&#8217;<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0441\u0431\u043e\u0440\u043a\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0435\u0441\u0442\u044c \u0432\u0441\u044f\u043a\u0438\u0435 <code>.\/configure<\/code>, <code>.\/buildconf<\/code> \u0438 \u043f\u0440\u043e\u0447\u0435\u0435 &#8212; \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u044d\u0442\u043e \u0432 <code>cmake<\/code>. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0430\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 <code>cmake<\/code> + <code>make<\/code>. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u044b\u043b \u0438 <code>.\/configure<\/code> \u0438 <code>.\/buildconf<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u0431\u043e\u0440\u043a\u0443 (\u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0441\u044f \u0432 \u0441\u0432\u043e\u0435\u0439 \u043f\u0430\u043f\u043a\u0435, \u0435\u0433\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438 \u0440\u044f\u0434\u043e\u043c \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438). \u042f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u043e\u0447\u0438\u043d\u0438\u043b \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u043c\u043e\u0433\u0443 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u043f\u0443\u0442\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 cmake.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0440\u0433\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0449\u0435\u0442 kphp<\/h3>\n<p>\u041a\u043e\u0433\u0434\u0430 kphp \u0431\u0443\u0434\u0435\u0442 \u0431\u0438\u043b\u0434\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0440\u0433\u0435\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0437\u043d\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 <code>include<\/code> \u0438 \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430.<br \/> \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>libmbfl<\/code>, \u0442\u043e\u0433\u0434\u0430 kphp \u0431\u0443\u0434\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0430\u0440\u0433\u0435\u0442\u044b:<\/p>\n<ol>\n<li>\n<p>libmbfl<\/p>\n<\/li>\n<li>\n<p>libmbfl_ALL_SOURCES<\/p>\n<\/li>\n<li>\n<p>libmbfl-includecopy<\/p>\n<\/li>\n<\/ol>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439, \u043d\u0430\u0447\u043d\u0435\u043c \u0441 <code>libmbfl<\/code>.<\/p>\n<h3>libmbfl<\/h3>\n<pre><code class=\"cmake\">project(libmbfl         VERSION 1.0.0         DESCRIPTION \"libmbfl\"         HOMEPAGE_URL \"https:\/\/github.com\/andreylzmw\/libmbfl\") # ... set_target_properties(libmbfl PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${OBJS_DIR}) # ... set_target_properties(libmbfl PROPERTIES PUBLIC_HEADER \"libmbfl\/mbfilter.h\") # ...  add_dependencies(libmbfl libmbfl-includecopy) # ... install(TARGETS libmbfl         COMPONENT KPHP         LIBRARY DESTINATION \"${CMAKE_INSTALL_PREFIX}\/${CMAKE_INSTALL_LIBDIR}\"         ARCHIVE DESTINATION \"${CMAKE_INSTALL_PREFIX}\/${CMAKE_INSTALL_LIBDIR}\"         PUBLIC_HEADER DESTINATION \"${CMAKE_INSTALL_PREFIX}\/${CMAKE_INSTALL_INCLUDEDIR}\/kphp\/liblibmbfl\") # ... add_library(libmbfl STATIC ${libmbfl_ALL_SOURCES}) add_library(vk::libmbfl ALIAS libmbfl)<\/code><\/pre>\n<h3>libmbfl_ALL_SOURCES<\/h3>\n<pre><code class=\"cmake\">set(libmbfl_ALL_SOURCES     filters\/mbfilter_iso2022_jp_ms.c filters\/mbfilter_iso8859_14.c filters\/mbfilter_iso8859_6.c filters\/mbfilter_sjis_mobile.c filters\/mbfilter_koi8r.c filters\/mbfilter_cp850.c filters\/mbfilter_euc_jp.c # ... add_library(libmbfl STATIC ${libmbfl_ALL_SOURCES}) # ...<\/code><\/pre>\n<h3>libmbfl-includecopy<\/h3>\n<pre><code class=\"cmake\">add_dependencies(libmbfl libmbfl-includecopy) # ... add_custom_command(         COMMAND cp -R                 ${CMAKE_CURRENT_SOURCE_DIR}\/mbfl                 ${CMAKE_CURRENT_SOURCE_DIR}\/include\/kphp\/libmbfl         OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}\/include\/kphp\/libmbfl\/mbfl)  add_custom_command(         COMMAND cp -R                 ${CMAKE_CURRENT_SOURCE_DIR}\/filters                 ${CMAKE_CURRENT_SOURCE_DIR}\/include\/kphp\/libmbfl         OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}\/include\/kphp\/libmbfl\/filters)  add_custom_command(         COMMAND cp -R                 ${CMAKE_CURRENT_SOURCE_DIR}\/nls                 ${CMAKE_CURRENT_SOURCE_DIR}\/include\/kphp\/libmbfl         OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}\/include\/kphp\/libmbfl\/nls) # ... add_custom_target(libmbfl-includecopy ALL DEPENDS  include\/kphp\/libmbfl\/mbfl\/mbfilter.h) # ...<\/code><\/pre>\n<h4>\u0412\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u0438 \u043b\u0438\u043d\u043a\u043e\u0432\u043a\u0443 \u0432 cmake. cmake\/external-libraries.cmake:<\/h4>\n<pre><code class=\"cmake\"># ... FetchContent_Declare(libmbfl GIT_REPOSITORY https:\/\/github.com\/andreylzmw\/libmbfl) FetchContent_MakeAvailable(libmbfl) include_directories(${libmbfl_SOURCE_DIR}\/include) add_definitions(-DLIBMBFL_LIB_DIR=\"${libmbfl_SOURCE_DIR}\/objs\") add_link_options(-L${libmbfl_SOURCE_DIR}\/objs) # ...<\/code><\/pre>\n<h4>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0432 \u0438\u043c\u043f\u043e\u0440\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430<\/h4>\n<p>\u0427\u0442\u043e\u0431\u044b kphp \u043c\u043e\u0433 \u043b\u0438\u043d\u043a\u043e\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <code>libmbfl<\/code> \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0435 (\u0431\u0435\u0437 <code>lib<\/code> \u0432 \u043d\u0430\u0447\u0430\u043b\u0435) \u0432 <code>external_static_libs<\/code> \u0432 <code>compiler\/compiler-settings.cpp<\/code>:<\/p>\n<pre><code class=\"cpp\">std::vector&lt;vk::string_view> external_static_libs{..., \"mbfl\"};<\/code><\/pre>\n<h3>\u0422\u0435\u0441\u0442\u044b<\/h3>\n<h4>cpp \u0442\u0435\u0441\u0442\u044b<\/h4>\n<p>cpp \u0442\u0435\u0441\u0442\u044b \u044d\u0442\u043e \u0442\u0435\u0441\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441test. \u0412 \u043d\u0438\u0445 \u043c\u044b \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u043d\u0430\u0442\u044c \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c. \u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u043e. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442. cpp \u0442\u0435\u0441\u0442\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 <code>tests\/cpp\/runtime\/<\/code>. \u0427\u0442\u043e\u0431\u044b \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u043c <code>mbstring-test.cpp<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 <code>tests\/cpp\/runtime\/<\/code>:<\/p>\n<pre><code class=\"cpp\">#include &lt;gtest\/gtest.h> #include \"runtime\/mbstring\/mbstring.h\"  \/\/ Note: all tests written for php8.3  \/* TEST ASCII DATA *\/ const string &amp;ASCII_STRING = string(\"sdf234\"); const array&lt;string> &amp;ASCII_ARRAY = array&lt;string>::create(string(\"234\"), string(\"wef\")); const string &amp;ASCII_ENCODING = string(\"ASCII\");  \/* TEST WINDOWS1251 DATA *\/ const string &amp;WINDOWS1251_STRING = string(\"sdfw3234\u044b\u0432\u0430\"); const array&lt;string> &amp;WINDOWS1251_ARRAY = array&lt;string>::create(string(\"234\"), string(\"wef\"), string(\"\u044b\u0432\u0430\")); const string &amp;WINDOWS1251_ENCODING = string(\"Windows-1251\");  \/* TEST UTF8 DATA *\/ const string &amp;UTF8_STRING = string(\"\u04e8d5\u043f\u0430\"); const array&lt;string> &amp;UTF8_ARRAY = array&lt;string>::create(string(\"sd\u0421\u2039\u0420\u00b0\"), string(\"wef\"), string(\"\u044b\u0432\u0430\"), string(\"\u04e8\"), string(\"\u00c4\u00b0nan\u00c3\u00a7 Esaslar\u00c4\u00b1\")); const string &amp;UTF8_ENCODING = string(\"UTF-8\");  #ifdef MBFL  TEST(mbstring_test, test_mb_check_encoding) { \/* TEST ASCII ENCODING *\/ ASSERT_TRUE(f$mb_check_encoding(ASCII_STRING, ASCII_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(ASCII_ARRAY, ASCII_ENCODING)); ASSERT_FALSE(f$mb_check_encoding(WINDOWS1251_STRING, ASCII_ENCODING)); ASSERT_FALSE(f$mb_check_encoding(WINDOWS1251_ARRAY, ASCII_ENCODING)); ASSERT_FALSE(f$mb_check_encoding(UTF8_STRING, ASCII_ENCODING)); ASSERT_FALSE(f$mb_check_encoding(UTF8_ARRAY, ASCII_ENCODING));  \/* TEST WINDOWS1251 ENCODING *\/ ASSERT_TRUE(f$mb_check_encoding(WINDOWS1251_STRING, WINDOWS1251_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(WINDOWS1251_ARRAY, WINDOWS1251_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(ASCII_STRING, WINDOWS1251_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(ASCII_ARRAY, WINDOWS1251_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(UTF8_STRING, WINDOWS1251_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(UTF8_ARRAY, WINDOWS1251_ENCODING));  \/* TEST UTF8 ENCODING *\/ ASSERT_TRUE(f$mb_check_encoding(UTF8_STRING, UTF8_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(UTF8_ARRAY, UTF8_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(ASCII_STRING, UTF8_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(ASCII_ARRAY, UTF8_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(WINDOWS1251_STRING, UTF8_ENCODING)); ASSERT_TRUE(f$mb_check_encoding(WINDOWS1251_ARRAY, UTF8_ENCODING)); }  TEST(mbstring_test, test_mb_convert_encoding) { \/* input is string, encoding is string *\/ ASSERT_STREQ(f$mb_convert_encoding(ASCII_STRING, WINDOWS1251_ENCODING, ASCII_ENCODING).to_string().c_str(), ASCII_STRING.c_str()); ASSERT_STREQ(f$mb_convert_encoding(UTF8_STRING, UTF8_ENCODING, UTF8_ENCODING).to_string().c_str(), UTF8_STRING.c_str());  \/* input is string, encoding is array of strings *\/ ASSERT_STREQ(f$mb_convert_encoding(ASCII_STRING, {WINDOWS1251_ENCODING, UTF8_ENCODING}, ASCII_ENCODING).to_string().c_str(), {ASCII_STRING.c_str(), UTF8_STRING.c_str()}); }  #endif<\/code><\/pre>\n<p>\u0421\u0431\u043e\u0440\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <code>tests\/cpp\/runtime\/runtime-tests.cmake<\/code>, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c cpp \u0444\u0430\u0439\u043b \u0432 <code>RUNTIME_TESTS_SOURCES<\/code>:<\/p>\n<pre><code class=\"cmake\">prepend(RUNTIME_TESTS_SOURCES ${BASE_DIR}\/tests\/cpp\/runtime\/ # ... mbstring-test.cpp # ...<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c ctest:<\/p>\n<pre><code>cd build &amp;&amp; ctest -j$(nproc)<\/code><\/pre>\n<p>\u041c\u044b \u0443\u0432\u0438\u0434\u0438\u043c:<\/p>\n<pre><code>... 242\/261 Test #242: mbstring_test.test_mb_check_encoding .......................................   Passed    0.24 sec 243\/261 Test #243: mbstring_test.test_mb_convert_encoding .....................................   Passed    0.23 sec ...<\/code><\/pre>\n<h4>php \u0442\u0435\u0441\u0442\u044b<\/h4>\n<p>php \u0442\u0435\u0441\u0442\u044b \u044d\u0442\u043e \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b php \u0438 kphp, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>tests\/kphp_tester.py<\/code>. \u0412 \u043d\u0438\u0445 \u043c\u044b \u043f\u0438\u0448\u0435\u043c php \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0432 kphp. php \u0442\u0435\u0441\u0442\u044b \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 <code>tests\/phpt\/<\/code>. \u0427\u0442\u043e\u0431\u044b \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 <code>mbstring<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 <code>tests\/phpt\/<\/code>. \u0412\u043d\u0443\u0442\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <code>001_*****.php<\/code>, <code>002_*****.php<\/code> \u0438 \u0442\u0434, \u0433\u0434\u0435 <code>*****<\/code> &#8212; \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435:<br \/> <code>tests\/phpt\/mbstring\/001_mb_convert_encoding.php<\/code>:<\/p>\n<pre><code class=\"php\">@ok &lt;?php  function mb_convert_encoding_not_utf_8() {   $str = \"Somebody was told: F$#$)UT#*HD]\";   var_dump(mb_convert_encoding($str, \"UTF-7\", \"EUC-JP\")); }  # If mbstring.language is \"Japanese\", \"auto\" is expanded to \"ASCII,JIS,UTF-8,EUC-JP,SJIS\" function test_mb_convert_encoding_auto() {   $str = \"Somebody was told: F$#$)UT#*HD]\";   var_dump(mb_convert_encoding($str, \"EUC-JP\", \"auto\")); }  mb_convert_encoding_not_utf_8(); test_mb_convert_encoding_auto();<\/code><\/pre>\n<p><code>tests\/phpt\/mbstring\/002_mb_check_encoding.php<\/code>:<\/p>\n<pre><code class=\"php\">@ok &lt;?php  function mb_check_encoding_utf_8() {   $str = \"The leading horse is white, the second horse is red, the third one is black, the last one is green\";   var_dump(mb_check_encoding($str, \"UTF-8\")); }  function mb_check_encoding_not_utf_8() {   $str = \"The leading horse is white, the second horse is red, the third one is black, the last one is green\";   var_dump(mb_check_encoding($str, \"base64\")); }  mb_check_encoding_utf_8(); mb_check_encoding_not_utf_8();<\/code><\/pre>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 kphp \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p><code>@ok<\/code>, \u0435\u0441\u043b\u0438 kphp \u0434\u043e\u043b\u0436\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434<\/p>\n<\/li>\n<li>\n<p><code>@kphp_should_fail<\/code>, \u0435\u0441\u043b\u0438 kphp \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0438 \u044d\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e<\/p>\n<\/li>\n<li>\n<p><code>@kphp_should_warn<\/code>, \u0435\u0441\u043b\u0438 kphp \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0438 \u044d\u0442\u043e \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e + \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u043e\u0440\u043d\u0438\u043d\u0433<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0435\u0441\u0442\u044b:<br \/> <code>.\/kphp_tester.py phpt\/mbstring\/001_mb_convert_encoding.php<\/code>: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c19\/c5a\/c4e\/c19c5ac4eb6d11760ebcae853927f3af.png\" alt=\"\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-07-21 \u0432 23 50 08\" width=\"942\" height=\"86\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c19\/c5a\/c4e\/c19c5ac4eb6d11760ebcae853927f3af.png\"\/><\/p>\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-07-21 \u0432 23 50 08<\/figcaption><\/div>\n<\/figure>\n<p><code>.\/kphp_tester.py phpt\/mbstring\/002_mb_check_encoding.php<\/code>: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ac0\/fb7\/a8c\/ac0fb7a8cf92afbbb8a89351750ed804.png\" alt=\"\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-07-21 \u0432 23 49 42\" width=\"939\" height=\"89\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ac0\/fb7\/a8c\/ac0fb7a8cf92afbbb8a89351750ed804.png\"\/><\/p>\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-07-21 \u0432 23 49 42<\/figcaption><\/div>\n<\/figure>\n<h4>pull_request<\/h4>\n<p>\u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0443\u0447\u043b\u0438 \u0432\u0441\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0442\u0435\u0441\u0442\u044b. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c pull_request. \u041d\u0435 \u043f\u043e\u0432\u0435\u0440\u0438\u0442\u0435, \u043d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e-\u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u043f\u043e\u0433\u043e\u0440\u0435\u043b. <strong>\u041b\u043e\u043c\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c<\/strong> &#8212; \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0446\u0435\u043b\u0435\u0432\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0434\u043b\u044f kphp \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f vk. vk \u044d\u0442\u043e \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u0438\u0437 \u0431\u043e\u043b\u0435\u0435 9 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430 \u043d\u0430 php. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0435 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0432\u043e\u0438\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e (\u043a\u0430\u043a \u044f \u0437\u0430\u043c\u0435\u043d\u0438\u043b \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 mbstring \u0441\u0432\u043e\u0438\u043c\u0438), \u0442\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c vk \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0441\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0447\u0442\u043e \u0438\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a vk \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0431\u0435\u0437 \u0432\u0430\u0448\u0438\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 (\u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445) \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043f\u043e \u0444\u043b\u0430\u0433\u0430\u043c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u044e\u0442 \u0432\u0441\u0435. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 vk \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u043a\u043e\u0434 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 kphp \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0430\u0448 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0434\u043b\u044f \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>\u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b \u043e\u0441\u043e\u0431\u043e \u043d\u0435\u0442 &#8212; \u043f\u0438\u0448\u0438\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438. \u041c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0432\u044c\u044e \u043f\u0440\u043e\u0449\u0435, \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0432 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0432\u044b \u0432\u0437\u044f\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438. \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043d\u044e\u0430\u043d\u0441\u044b (\u043f\u043e \u0442\u0438\u043f\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0441\u0432\u043e\u044e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443), \u0442\u043e\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0438\u0448\u0438\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/749792\/\"> https:\/\/habr.com\/ru\/articles\/749792\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 KPHP<\/h3>\n<figure class=\"full-width\">\n<div><figcaption>kphp-1<\/figcaption><\/div>\n<\/figure>\n<p>KPHP &#8212; \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u043b\u044f PHP. \u041e\u043d \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 PHP \u043a\u043e\u0434 \u0432 \u043a\u043e\u0434 \u043d\u0430 C++, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0443\u0441\u043a\u043e\u0440\u044f\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0440\u0430\u0437. \u042d\u0442\u043e open-source \u043f\u0440\u043e\u0435\u043a\u0442, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435 \u043d\u0430 9 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0441\u0442\u0440\u043e\u043a PHP \u043a\u043e\u0434\u0430 \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u0438\u043a, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0412\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u0435.<\/p>\n<h3>\u0426\u0435\u043b\u044c<\/h3>\n<p>\u042f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 runtime KPHP. \u0422\u043e\u0447\u043d\u0435\u0435 \u043f\u0440\u043e \u0442\u0435\u0440\u043d\u0438\u0441\u0442\u0443\u044e \u0434\u043e\u0440\u043e\u0433\u0443 \u043d\u0430 \u043f\u0443\u0442\u0438.<\/p>\n<h3>\u041f\u043b\u0430\u043d<\/h3>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/p>\n<\/li>\n<li>\n<p>runtime <\/p>\n<ul>\n<li>\n<p>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0442\u0438\u043f\u044b<\/p>\n<\/li>\n<li>\n<p>\u0444\u043b\u0430\u0433\u0438<\/p>\n<\/li>\n<li>\n<p>\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0422\u0435\u0441\u0442\u044b <\/p>\n<ul>\n<li>\n<p>cpp \u0442\u0435\u0441\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>php \u0442\u0435\u0441\u0442\u044b<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>pull_request<\/p>\n<\/li>\n<\/ol>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430<\/h3>\n<p><a href=\"https:\/\/vkcom.github.io\/kphp\/kphp-internals\/developing-and-extending-kphp\/compiling-kphp-from-sources.html\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c kphp \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/a><\/p>\n<h3>runtime<\/h3>\n<h4>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439<\/h4>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>mb_check_encoding<\/code> \u0438\u0437 php. \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0438\u0434\u0435\u043c \u0432 \u0434\u043e\u043a\u0438: <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 01 39 38<\/figcaption><\/div>\n<\/figure>\n<p>\u0423\u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0442\u0440\u043e\u043a. \u041c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u0444\u043e\u043a\u0443\u0441\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0434\u0435\u043c \u0432 <a href=\"https:\/\/github.com\/php\/php-src\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434 php<\/a> \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432 php: <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 01 51 49<\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0438\u0448\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0442\u0440\u0435\u0439\u0441\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e: <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 01 55 59<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0438\u0434\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0442\u0438\u043f\u0430 <code>mbfl_encoding<\/code>. \u0418\u0449\u0435\u043c: <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 02 12 42<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 &#8212; \u0447\u0430\u0441\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>libmbfl<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0438\u0434\u0438\u043c\u043e \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0435\u0439. \u0418\u0449\u0435\u043c \u0435\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439: <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 02 10 43<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043e\u0437\u044c\u043c\u0435\u0442 \u0432\u0441\u044e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u043d\u0430 \u0441\u0435\u0431\u044f, \u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u044d\u0442\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c, \u0438\u0437\u0443\u0447\u0430\u0435\u043c \u0435\u0435 \u0438 \u043f\u0438\u0448\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u0438\u0448\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0438\u043a\u0435 (\u043d\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 kphp, \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u043c \u043d\u0430\u0434\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e). \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0443\u0436\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 <code>mb_convert_encoding<\/code>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0442\u043e\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c:<\/p>\n<pre><code class=\"cpp\">#include &lt;libmbfl\/mbfl\/mbfilter.h>  mbfl_string *mb_convert_encoding(const char *str, const char *to, const char *from) {  int len = strlen(str); enum mbfl_no_encoding from_encoding, to_encoding; mbfl_buffer_converter *convd = NULL; mbfl_string _string, result, *ret;  \/* from internal to mbfl *\/ from_encoding = mbfl_name2no_encoding(from); to_encoding = mbfl_name2no_encoding(to);  \/* init buffer mbfl strings *\/ mbfl_string_init(&amp;_string); mbfl_string_init(&amp;result); _string.no_encoding = from_encoding; _string.len = len; _string.val = (unsigned char*)str;  \/* converting *\/ convd = mbfl_buffer_converter_new(from_encoding, to_encoding, 0); ret = mbfl_buffer_converter_feed_result(convd, &amp;_string, &amp;result); mbfl_buffer_converter_delete(convd);  \/* fix converting with multibyte encodings *\/ if (len % 2 != 0 &amp;&amp; ret->len % 2 == 0 &amp;&amp; len &lt; ret->len) { ret->len++; ret->val[ret->len-1] = 63; }  return ret; }  bool mb_check_encoding(const char *value, const char *encoding) {  \/* init buffer mbfl strins *\/ mbfl_string _string; mbfl_string_init(&amp;_string); _string.val = (unsigned char*)value; _string.len = strlen((char*)value);  \/* from internal to mbfl *\/ const mbfl_encoding *enc = mbfl_name2encoding(encoding);  \/* get all supported encodings *\/ const mbfl_encoding **encs = mbfl_get_supported_encodings(); int len = sizeof(**encs);  \/* identify encoding of input string *\/ \/* Warning! String can be represented in different encodings, so check needed *\/ const mbfl_encoding *i_enc = mbfl_identify_encoding2(&amp;_string, encs, len, 1);  \/* perform convering *\/ const char *i_enc_str = (const char*)mb_convert_encoding(value, i_enc->name, enc->name)->val; const char *enc_str = (const char*)mb_convert_encoding(i_enc_str, enc->name, i_enc->name)->val;  \/* check equality *\/ \/* Warning! strcmp not working, because of different encodings *\/ bool res = true; for (int i = 0; i &lt; strlen(enc_str); i++) if (enc_str[i] != value[i]) { res = false; break; }  free((void*)i_enc_str); free((void*)enc_str); return res; } <\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u0438\u0448\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 runtime kphp. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c 4 \u0448\u0430\u0433\u0430:<\/p>\n<ol>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c php-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (txt)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c (h)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 (cpp)<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u0441\u0431\u043e\u0440\u043a\u0443 (cmake)<\/p>\n<\/li>\n<\/ol>\n<h3>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c php-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (txt)<\/h3>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 php \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u0440\u043e \u0442\u0438\u043f\u044b \u0432 kphp <a href=\"https:\/\/vkcom.github.io\/kphp\/kphp-language\/static-type-system\/kphp-type-system.html\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a> <\/p>\n<figure class=\"full-width\">\n<div><figcaption>kphp-types<\/figcaption><\/div>\n<\/figure>\n<p>\u0418\u0442\u0430\u043a, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b <code>builtin-functions\/_functions.txt<\/code>. \u0418 \u0432 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u043d\u0435\u0446 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438\u0437 php. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 php mb_check_encoding \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441:<\/p>\n<pre><code class=\"php\">function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool<\/code><\/pre>\n<p>\u0432 kphp \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442:<\/p>\n<pre><code class=\"php\">function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool;<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f mb_convert_encoding \u0432 php:<\/p>\n<pre><code class=\"php\">function mb_convert_encoding(array|string $string, string $to_encoding, array|string|null $from_encoding = null): array|string|false<\/code><\/pre>\n<p>\u0432 kphp:<\/p>\n<pre><code class=\"php\">function mb_convert_encoding(array|string $string, string $to_encoding, array|string|null $from_encoding = null): array|string|false;<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434.<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c (h)<\/h3>\n<p>\u0412\u0441\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 <code>runtime<\/code>. \u041d\u0430\u0448\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f <code>mbstring<\/code> \u0434\u043b\u044f php. \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b\u0438\u043a <code>mbstring.h<\/code>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c: <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 23 27 45<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f mb_check_encoding \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430, \u0441\u0442\u0440\u0430\u043d\u043d\u043e. \u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <code>f$<\/code>? \u0422\u0430\u043a kphp \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u0435 \u043a\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 <code>builtin-functions\/_functions.txt<\/code>. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c cpp \u0444\u0430\u0439\u043b: <\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u043d\u0438\u043c\u043e\u043a \u044d\u043a\u0440\u0430\u043d\u0430 2023-06-02 \u0432 22 25 11<\/figcaption><\/div>\n<\/figure>\n<p>\u0425\u043c, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430, \u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043e\u043a (UTF-8 \u0438 Windows-1251). \u041d\u0438\u0447\u0435\u0433\u043e \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0433\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u0438\u043c \u0432\u0441\u0435 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438! (\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u0445 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0432 \u043a\u043e\u043d\u0446\u0435). \u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u0430 <code>string<\/code>. \u041b\u043e\u0432\u0443\u0448\u043a\u0430! \u042d\u0442\u043e \u043d\u0435 string \u0438\u0437 I\/O! \u042d\u0442\u043e string \u0438\u0437 kphp! \u0413\u0434\u0435 \u043f\u0440\u043e \u043d\u0435\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c? \u0412\u0441\u0435 \u0442\u0438\u043f\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0438\u0437 <code>runtime\/kphp_core.h<\/code>. \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u043d\u0443\u0442\u0440\u0438: . \u041f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>mb_check_encoding<\/code>:<\/p>\n<pre><code class=\"cpp\">bool f$mb_check_encoding(const string &amp;value, const string &amp;encoding);<\/code><\/pre>\n<p>\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f <code>mb_convert_encoding<\/code>:<\/p>\n<pre><code class=\"cpp\">string f$mb_convert_encoding(const string &amp;str, const string &amp;to_encoding, const string &amp;from_encoding);<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0438\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 (cpp)<\/h3>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0432\u0441\u0435 \u0442\u0438\u043f\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <code>string.inl<\/code> \u0438 \u0443\u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c \u0438\u0437 \u043d\u0435\u0435 <code>const char *<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0438\u043b\u0438 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c string \u0438\u0437 <code>const char *<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>mb_check_encoding<\/code>:<\/p>\n<pre><code class=\"cpp\">bool f$mb_check_encoding(const string &amp;value, const string &amp;encoding) { const char *c_encoding = encoding.c_str(); const char *c_value = value.c_str(); \/\/ ... }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>mb_convert_encoding<\/code>:<\/p>\n<pre><code class=\"cpp\">string f$mb_convert_encoding(const string &amp;str, const string &amp;to_encoding, const string &amp;from_encoding) { const char *c_string = s.c_str(); const char *c_to_encoding = to_encoding.c_str(); const char *c_from_encoding = from_encoding.c_str(); \/\/ ... return string((const char*)ret->val, ret->len); }<\/code><\/pre>\n<h3>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0432 \u0441\u0431\u043e\u0440\u043a\u0443 (cmake)<\/h3>\n<p>\u0418\u0434\u0435\u043c \u0432 <code>runtime\/runtime.cmake<\/code>. \u0412\u0441\u0435 cpp \u0434\u043e\u043b\u0436\u043d\u044b \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0432 <code>KPHP_RUNTIME_SOURCES<\/code>. \u041d\u043e \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>mbstring.cpp<\/code> \u0443\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u0432 \u0441\u0431\u043e\u0440\u043a\u0443. \u041d\u043e, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443:<\/p>\n<pre><code class=\"cmake\">prepend(KPHP_RUNTIME_MBSTRING_SOURCES         mbstring.cpp)<\/code><\/pre>\n<p>\u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432 <code>KPHP_RUNTIME_SOURCES<\/code> \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>mbstring.cpp<\/code>, \u0430 <code>KPHP_RUNTIME_MBSTRING_SOURCES<\/code>:<\/p>\n<pre><code class=\"cmake\">prepend(KPHP_RUNTIME_SOURCES ${BASE_DIR}\/runtime\/         ${KPHP_RUNTIME_MBSTRING_SOURCES} ...<\/code><\/pre>\n<p>\u0424\u0443\u0445, \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u043e\u0447\u043d\u043e \u0432\u0441\u0435. \u0411\u0438\u043b\u0434\u0438\u043c!<\/p>\n<pre><code>mkdir build &amp;&amp; cd build &amp;&amp; cmake .. -DDOWNNLOAD_MISSING_LIBRARIES=On &amp;&amp; make -j$(nproc)<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c test.php:<\/p>\n<pre><code class=\"php\">echo mb_check_encoding(\"Hello World\", \"UTF-8\");<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c!<\/p>\n<pre><code>.\/objs\/bin\/kphp2cpp -M test.php &amp;&amp; .\/kphp_out\/cli<\/code><\/pre>\n<p>\u0423\u0440\u0430! \u041c\u044b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c kphp!<\/p>\n<h4>!!! \u0412\u0430\u0436\u043d\u043e !!!<\/h4>\n<p>\u041d\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u041c\u044b \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 (\u043b\u0438\u0448\u044c \u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e). \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u0431\u0435\u0434\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b.<\/p>\n<ol>\n<li>\n<p>\u0418 \u0431\u044b\u043b\u043e \u0431\u044b \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0442\u043e\u043d\u043e\u043c \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0435\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 php. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 php <code>mb_convert_encoding<\/code> \u0435\u0441\u043b\u0438 \u043f\u0440\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0435\u0441\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0435, \u0442\u043e \u0438\u0445 \u0431\u0430\u0439\u0442\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 0x63 (&#8216;?&#8217; \u0432 ASCII). \u042d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0435\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 <code>f$<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0430 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0443\u0436\u043d\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0438\u043f\u044b &#8212; <code>mb_check_en\u0441oding<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a \u0438\u043b\u0438 <code>null<\/code>, \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c. \u041f\u0440\u0438\u0447\u0435\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u043e php (\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 php \u043d\u0435\u043b\u043e\u0433\u0438\u0447\u043d\u043e). \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f <code>mb_convert_encoding<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0438 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<\/li>\n<li>\n<p><code>mbstring<\/code> \u044d\u0442\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 kphp, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 <code>php-src<\/code>, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0444\u043b\u0430\u0433 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u044d\u0442\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 php.<\/p>\n<\/li>\n<\/ol>\n<h4>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u0442\u043e\u043d<\/h4>\n<ol>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>const &amp;<\/code> \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u043d\u0435 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f)<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u0432 php (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>static<\/code>):<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">static bool check_en\u0441oding(const char *value, const char *encoding) { \/\/ ... }  bool f$mb_check_encoding(const string &amp;value, const string &amp;encoding) { const char *c_encoding = encoding.c_str(); const char *c_value = value.c_str(); bool res = check_en\u0441oding(c_value, c_encoding); \/\/ process differences in php return res }<\/code><\/pre>\n<ol start=\"3\">\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>noexcept<\/code> \u0435\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"cpp\">static bool check_en\u0441oding(const char *value, const char *encoding) { \/\/ ... }  bool f$mb_check_encoding(const string &amp;value, const string &amp;encoding) noexcept { const char *c_encoding = encoding.c_str(); const char *c_value = value.c_str(); bool res = check_en\u0441oding(c_value, c_encoding); \/\/ process differences in php return res }<\/code><\/pre>\n<h4>\u0422\u0438\u043f\u044b<\/h4>\n<p><code>mb_check_encoding<\/code> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c <code>string|array|null<\/code> (\u0441\u0443\u0434\u044f \u043f\u043e php-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443). \u0412 C++ \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0438\u043f\u044b \u0442\u0430\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0438\u043f \u043d\u0430 <code>mixed<\/code> (\u0441\u043c\u0435\u0448\u0430\u043d\u043d\u044b\u0439). \u041f\u0440\u043e <code>mixed<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u0438\u043f\u0443 <code>string<\/code>. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 <code>mb_check_encoding<\/code> (\u0441\u0443\u0434\u044f \u043f\u043e php-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443) \u0438\u043c\u0435\u0435\u0442 \u0442\u0438\u043f <code>?string<\/code>, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 <code>Optional&lt;string><\/code>. \u041f\u0440\u043e <code>Optional<\/code> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0442\u0438\u043f\u0443 <code>string<\/code>. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e <code>mixed<\/code> \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0442\u0438\u043f \u0447\u0435\u0440\u0435\u0437 <code>.is_&lt;\u0442\u0438\u043f><\/code> \u0438<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-350665","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=350665"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350665\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}