I'm trying to get url from request,
{{ craft.app.request.url }}
but the uri is chinese, like "localhost/測試",
it print out "http://localhost/����"
did i miss some setting in craft CMS ?
Thank you.
This isn't really an answer, but my investigating was too long for a comment.
Ultimately, craft.app.request.url
gets routed through Yii's resolveRequestUri() and likely gets pulled from $_SERVER['REQUEST_URI'].
Anything coming from $_SERVER['REQUEST_URI']
is always going to be URL encoded so using this in a template:
I get this URL encoded output in a browser:
Unfortunately, Twig doesn't have a |url_decode
filter, so you'd need to write a quick custom Twig filter that uses PHP's urldecode() method.
But it actually looks like you're having a character encoding issue first because of the ����
and I'm not exactly sure what's causing that.
My guess is its environment configuration related (I'm using https://getnitro.sh in a fairly default setup for testing).
<meta charset="UTF-8">
in your template?default_charset
, what is it set to?