Welcome Guest, Not a member yet? Register   Sign In
echo : default charset
#1

[eluser]Patrick Maciel | @p4designer[/eluser]
Hello everbody.

I have one simple question: why not get the CodeIgniter default charset defined in the config.php file to echo (php)?

I'm asking this because if I only want to display a message on the index () function of a controller, such as:
Code:
echo "Olá Mundo!";
I get invalid characters = 'á'.

But to solve this, is theoretically simple, just add this code:
Code:
header ('Content-Type: text / html; charset = utf-8');
, first line of the index ().

I know the HTML meta tags, etc.. But this is not the issue. I wish only to show a message with special characters.

Can you help me and/or explain to me why the CodeIgniter not get the default charset in config.php?

Sorry for my English, I am Brazilian and I need more practice.
#2

[eluser]bl00dshooter[/eluser]
[quote author="Patrick Maciel | @p4designer" date="1289095980"]Hello everbody.

I have one simple question: why not get the CodeIgniter default charset defined in the config.php file to echo (php)?

I'm asking this because if I only want to display a message on the index () function of a controller, such as:
Code:
echo "Olá Mundo!";
I get invalid characters = 'á'.

But to solve this, is theoretically simple, just add this code:
Code:
header ('Content-Type: text / html; charset = utf-8');
, first line of the index ().

I know the HTML meta tags, etc.. But this is not the issue. I wish only to show a message with special characters.

Can you help me and/or explain to me why the CodeIgniter not get the default charset in config.php?

Sorry for my English, I am Brazilian and I need more practice.[/quote]

Arquivo config.php:

Quote:/*
|--------------------------------------------------------------------------
| Default Character Set
|--------------------------------------------------------------------------
|
| This determines which character set is used by default in various methods
| that require a character set to be provided.
|
*/
$config['charset'] = "UTF-8";

Creio que seja isso?
PS: também sou brasileiro.
#3

[eluser]Patrick Maciel | @p4designer[/eluser]
Opa! Um brasileiro por aqui.
Sim, mas é essa a questão meu amigo. Já está configurado no arquivo config.php, e algo como:
Code:
function index() {
   echo 'Olá Mundo';
}
... resulta em caracteres inválidos. Ai pra resolver, eu tenho que fazer:
Code:
function index() {
   header('Content-Type: text/html; charset=utf-8');
   echo 'Olá Mundo';
}

For english users....
I've put in the config.php file as UTF-8 charset.
But as shown in the code above, only when inserted header (php), that the word 'Olá' is displayed correctly.

=/
#4

[eluser]bl00dshooter[/eluser]
[quote author="Patrick Maciel | @p4designer" date="1289098082"]Opa! Um brasileiro por aqui.
Sim, mas é essa a questão meu amigo. Já está configurado no arquivo config.php, e algo como:
Code:
function index() {
   echo 'Olá Mundo';
}
... resulta em caracteres inválidos. Ai pra resolver, eu tenho que fazer:
Code:
function index() {
   header('Content-Type: text/html; charset=utf-8');
   echo 'Olá Mundo';
}

For english users....
I've put in the config.php file as UTF-8 charset.
But as shown in the code above, only when inserted header (php), that the word 'Olá' is displayed correctly.

=/[/quote]

Bem, acredito que não há como alterar isso sem modificar o core, o que não é recomendado.
No mais, não use header no controller, todo output deve ser feito na view, com a metatag apropriada.
Usar header no controller é considerado bad practices.\
#5

[eluser]Patrick Maciel | @p4designer[/eluser]
Sim, entendo amigo.
Eu só questionei isso pois estou estudando e criando exemplos aqui e não quero criar 1 view para cada Controller... já que é apenas para teste.

Quanto as views, funciona perfeitamente, já criei 'n' exemplos'.

De qualquer forma, muito obrigado pela ajuda Wink
#6

[eluser]Patrick Maciel | @p4designer[/eluser]
So....
As I close this post or mark it as completed/solved?
It is the link echo "Un-subscribe from this thread"?
#7

[eluser]InsiteFX[/eluser]
That is because when index.php is loaded the config.php is not loaded until it loads the
CodeIgniter core at the end of index.php!

And thank you for translating to english...

InsiteFX
#8

[eluser]Patrick Maciel | @p4designer[/eluser]
[quote author="InsiteFX" date="1289107357"]That is because when index.php is loaded the config.php is not loaded until it loads the
CodeIgniter core at the end of index.php!

And thank you for translating to english...

InsiteFX[/quote]

Hmmm, I dont know that.
Anyway, now I understand ^^
Thank you so much my friend Smile




Theme © iAndrew 2016 - Forum software by © MyBB