Problems with $config['charset'] = 'UTF-8' in uppercase #1200

Closed
elrafael opened this Issue Mar 19, 2012 · 5 comments

Comments

Projects
None yet
4 participants

There is a stranger problem when I'm developing CI in Mac OS X enviroment.

If i maintain $config['charset'] = 'UTF-8' in uppercase, when I'm using form helper, I can't use latin chars.

Example:

view

<?php echo form_open(); ?>
<input type="text" name="field" value="<?php echo set_value('field'); ?>" /><br />
<button type="submit">Send</button>

controller

$this->load->library('form_validation');
$this->form_validation->set_rules('field', 'Field', 'required');
if ( $this->form_validation->run() === TRUE )
    var_dump( $this->input->post() );

If you enter this kind of text acentuação means accentuation the form_validation->run() will be always FALSE.

The solution is change the utf-8 text to lowercase, ie:
application/config/config.php
$config['charset'] = 'utf-8'; //Instead UTF-8.

system/core/Utf8.php

if (
            preg_match('/./u', 'é') === 1                  // PCRE must support UTF-8
            AND function_exists('iconv')                    // iconv must be installed
            AND ini_get('mbstring.func_overload') != 1      // Multibyte string function overloading cannot be enabled
            AND $CFG->item('charset') == 'utf-8'            // Application charset must be UTF-8 **LOWERCASE**
            )
        {

Regards,
Rafael V. de Oliveira

Contributor

diogoosorio commented Mar 19, 2012

I'm not being able to replicate this.

my enviroment is:

  • MAMP
  • PHP 5.3.6
  • MAC OS X 10.7.2

If i try this on Windows, no problem.

Contributor

diogoosorio commented Mar 19, 2012

I'm running a LAMP stack on Linux Mint and as I said previously I'm having an hard time replicating this. I think that this an issue with your environment, not with CodeIgniter itself.

After digging around Google a bit I've found this thread. It seems a specific issue with MAMP.

The workaround mentioned in the thread Diogo, is the same that I used. Maybe is a issue with MAMP or Mac OSX. As you wrote, you are using UNIX based system, in a first time i was thinking the problem is about case sensitive.

Anyway, I need to do more research and tests, but wrote here in case some other people have the same issue.

Thanks a lot!

@narfbg narfbg closed this Oct 5, 2012

Thanks!!
I was having this exact same issue, I am using Grocery Crud so I've started debugging that part of the application first.
the problem got solved by changing the db setting from UTF-8 uppercase to lowercase.

I am using MAMP,
PHP Version 5.3.5
Mac OsX 10.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment