I am using MS SQL Server and CodeIgniter 2 with Active Record for a project that I am working on and I just stumbled upon this problem:
When I submit a form containing Chinese or Hindi characters, I store it in a table, and when I look through it all I get is question marks. If I try English or Greek characters, everything seems to be working fine.
The reason I think this is due to the PHP that I am writing is because if I copy Chinese text directly to SQL Server Management Studio, all values are stored and displayed perfectly, both in SQL Studio and web Appendix.
These are the db settings I use:
$db['local']['dbdriver'] = 'sqlsrv'; $db['local']['dbprefix'] = ''; $db['local']['pconnect'] = FALSE; $db['local']['db_debug'] = TRUE; $db['local']['cache_on'] = FALSE; $db['local']['cachedir'] = ''; $db['local']['char_set'] = 'utf8'; $db['local']['dbcollat'] = 'utf8_general_ci'; $db['local']['swap_pre'] = ''; $db['local']['autoinit'] = TRUE; $db['local']['stricton'] = FALSE;
This is the table structure that I'm testing right now:
CREATE TABLE [dbo].[languages]( [id] [int] IDENTITY(1,1) NOT NULL, [language] [nvarchar](1024) NULL, [language_local] [nvarchar](1024) NULL, [lang_code] [nvarchar](100) NULL, [core] [bit] NULL, CONSTRAINT [PK_languages] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO
And this is my encoding encoding in config.php
$config['charset'] = 'utf-8';
New troubleshooting information
I tried to save the following line in my form: Iñtërnâtiônàlizætiøn
CodeIgniter responded with this error:
An error occurred translating the query string to UTF-16: No mapping for the Unicode character exists in the target multi-byte code page. .
This does not appear when I try to store Chinese characters Thank you in advance :)