Welcome Guest, Not a member yet? Register   Sign In
Unicode encoding issues in CI
#1

[eluser]Maglok[/eluser]
I have a utf8_unicode database in which I can insert a "©" mark manually no problem.

Once I try to do it through a field in an app made in Codeigniter I get some errors.

I am wondering how CI is dealing with it, I can't seem to add the really strange characters.

For example the string "©©©" gives me this error:

Code:
Incorrect string value: '\xA9\xA9\xA9' for column 'thesis_abstract' at row 1

I must not be dealing with the unicode correctly someway. Does anyone have a idea?
#2

[eluser]Zero-10[/eluser]
I would avoid programming that way and simply inserting HTML ASCII like this '©©©'. This will also resolve a lot of issues that occur with the user's browser and language settings, at least from what I've experienced since I deal with a foreign site. Let me know if that is a sufficient response to your problem.

Code:
©©©
Sorry, the forums automatically converted the ASCII lmao
#3

[eluser]Maglok[/eluser]
So you recommend getting everything to go through htmlentities php function?
#4

[eluser]InsiteFX[/eluser]
You can try this:
Code:
string htmlentities ( string $string [, int $flags = ENT_COMPAT [, string $charset [, bool $double_encode = true ]]] )

Make sure you set the charset!

InsiteFX
#5

[eluser]Maglok[/eluser]
Hmm yeah I am applying it to a '©' character, but I get errors to the tune of

Code:
A PHP Error was encountered
Severity: Warning

Message: htmlentities(): Invalid multibyte sequence in argument

Filename: controllers/application.php

Line Number: 229

I am wondering if © even translates to htmlentities or if I have to go for something like utf8_encode or somesuch.
#6

[eluser]n0xie[/eluser]
Are you sure the string you are handling is UTF-8? Else take a look at mb-check-encoding. CI has no issues with handling UTF-8 as long as you do make sure everything is UTF-8. If you get data through POST data, makes sure that accept-encoding is set to UTF-8.
#7

[eluser]InsiteFX[/eluser]
You could also try saving as this!
Code:
©

InsiteFX
#8

[eluser]Maglok[/eluser]
I do get data through POST.

Accept-encoding is what exactly? I do have the default character set in CI set to UTF-8.

Maybe I should illustrate a bit more what I am trying to accomplish. Basically this is a system where promovendi can submit their thesis. Seeing as scientific people like that tend to use complicated things like alphas, betas, copyrights, etc. characters the system needs to accept those.

At the time of writing it does not do that.
#9

[eluser]n0xie[/eluser]
Code:
<form accept-charset="utf-8" …>
    …
</form>
#10

[eluser]Maglok[/eluser]
I did that, no dice I am afraid.

I just cant seem to grasp what I am doing. I want special characters like alpha, beta, copyright, etc. to be in the database and also to be taken out.

The form has a accept-charset="UTF-8"

The check_encoding told me it is not UTF-8, but ISO-8859-1. Though that ISO should not be able to encode the copyright or alpha, beta, etc.




Theme © iAndrew 2016 - Forum software by © MyBB