keboola/php-utils

View on GitHub
src/Keboola/Utils/stripInvalidUtf16.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php
namespace Keboola\Utils;

/**
 * Strip UTF16 surrogates
 *
 * @param $string
 * @return mixed
 */
function stripInvalidUtf16($string)
{
    $regex = "/(\\\\ud83c\\\\u[0-9a-f]{4})|(\\\\ud83d\\\\u[0-9a-f]{4})|(\\\\u[0-9a-f]{4})/i";

    return preg_replace($regex, '', $string);
}