N
N
Noob--Saibot2017-10-08 22:21:29
PHP
Noob--Saibot, 2017-10-08 22:21:29

I don't understand what is the encoding problem?

Hi all. Help, please, to understand in what a problem. I write in PHP. There is a line and in it you need to raise the first character to upper case. Just some kind of anomaly.

echo mb_convert_case("полимерная компьютерная линза", MB_CASE_TITLE, "UTF-8");

and as a result I get
полимерная Компьютерная Линза
In general nonsense ...
And if like this it doesn’t output anything, but if you take the first two characters, then it displays the first letter - p Tell me what to do ??? You need to uppercase the first letter.
echo mb_substr($string, 0, 1, "utf-8");

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Gogolinsky, 2017-10-08
@Noob--Saibot

There may be some non-printable character at the beginning. Do first trim();

S
synapse_people, 2017-10-08
@synapse_people

mb_internal_encoding("UTF-8");
function mb_ucfirst($text) {
    return mb_strtoupper(mb_substr($text, 0, 1)) . mb_substr($text, 1);
}
echo mb_ucfirst("тест\n");

*Copy-paste from stack overflows*

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question