Welcome Guest, Not a member yet? Register   Sign In
Codeigniter UTF-8 in loaded view within another view

(This post was last modified: 08-28-2015, 02:39 PM by ZeroNine.)

I'm having a strange issue with loaded views in Codeigniter 3.0.1. I'm trying to display Spanish characters within my application. I have set these settings below to get Spanish displaying properly in the initial view loaded from my controller.

This is set in the main index.php of codeigniter.
header('Content-Type: text/html; charset=utf-8');

I also have set this on the top of my HTML page mark up.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

So Spanish characters in the main HTML page is displaying properly. The problem is when I try to load another view inside the main HTML file.

  spanish here //displays properly

  <?php $this->load->view("page/somepage"); //Spanish in view does not format properly ?>


Any Spanish characters loaded inside this "somepage" view is not formatting properly.
Is this a bug?

What is the encoding of the saved view file?

I'm assuming what you are asking is what is the output for this:
echo $this->output->get_header('content-type');
inside the inner view file. It shows "text/html; charset=utf-8"

No, most IDE's can usually save the file with different character encodings. I'm wondering if you saved the ACTUAL file with an encoding other than utf-8.

Theme © iAndrew 2016 - Forum software by © MyBB