public static function replace($str, $search, $replace)
    {
        if (self::$use_mbstring) {
            $search_len  = mb_strlen($search);
            $replace_len = mb_strlen($replace);
            $search_pos  = mb_strpos($str, $search);
            while ($search_pos !== false) {
                $str = mb_substr($str, 0, $search_pos) .
                    $replace .
                    mb_substr($str, $search_pos + $search_len);
                $search_pos = mb_strpos($str, $search, $search_pos + $replace_len);
            }
        } else {
            $str = str_replace($search, $replace, $str);
        }
        
        return $str;
    }