<?php

class StringBuilder
{

    protected $string;

    public function __construct()
    {
        $this->string = "";
    }

    public function set($str)
    {
        if (mb_detect_encoding($str) != "UTF-8") {
            $this->string = iconv(mb_detect_encoding($str), "UTF-8", $str);
        } else {
            $this->string = $str;
        }
    }

    public function changeEncod($enc)
    {
        $this->string = iconv(mb_detect_encoding($str), $enc, $str);
    }

    public function getLength()
    {
        return mb_strlen($this->string);
    }

    public function chatAt($c)
    {
        return mb_substr($this->string, $c, 1);
    }

    public function concat($param)
    {
        $this->string += $param;
    }

    public function __toString()
    {
        return $this->string;
    }

}

$str = new StringBuilder();
$str->set("строка");
$str->changeEncod("ASCII");
if (mb_detect_encoding($str) != "UTF-8") {
    echo "не ютф";
}