Welcome Guest, Not a member yet? Register   Sign In
Experiencing a problem with UTF-8 and diacritics (characters with accents, etc.)
#4

[eluser]Rok Biderman[/eluser]
You're presenting charset only if validation==false. If you check out the source, you'll find you only get echo of string, no encoding is set.

This works, but is fugly:

Code:
function index()
{
  $this->load->library('form_validation');
  $this->form_validation->set_rules('title', 'Title', 'required');

  if ($this->form_validation->run() == false)
  {
    echo $this->the_form(null);
  }
  else
  {
   echo $this->the_form($this->input->post('title'));
  }
  }

function the_form($var = null)
{
  if (!$var) {
      $var = '&lt;form action="krneki" method="post" accept-charset="utf-8"&gt;&lt;p>Title: &lt;input type="text" name="title" id="title" accept-charset="utf-8" size="75" value="" /&gt;&lt;/p><p>&lt;input type="submit" name="submit" value="Search for duplicates" /&gt;&lt;/p>&lt;/form&gt;';
  }
  $string = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   &lt;html&gt;
   &lt;head&gt;
   &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
   &lt;/head&gt;
   &lt;body&gt;'.$var.
   '&lt;/body&gt;
   &lt;/html&gt;';
   return $string;
  }

Just so you know, a kitten dies every time you write your html in an echo. Says so here. Put it in your view instead.


Messages In This Thread
Experiencing a problem with UTF-8 and diacritics (characters with accents, etc.) - by El Forum - 03-21-2012, 06:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB