Welcome Guest, Not a member yet? Register   Sign In
Cannot store chinese characters in MSSQL
#1

[eluser]Loupax[/eluser]
Hello,

I'm working on a CI 2 application, and I'm having trouble storing multibyte characters to my MSSQL database.

The reason I believe this has to do with CodeIgniter and not SQL is because if I try to store a chinese string directly using SQL Server Management Studio, the string is stored just fine, but when I enter the same data through a form, all I get in the table are question marks where the characters should be.

These are my database settings:
Code:
$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;

And this is the structure of the table I'm currently testing on:

Code:
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 charset encoding setting in my config.php

Code:
$config['charset'] = 'utf-8';

Finally, all the strings are being validated by the form validation library with required|trim rules.

There is also a question made in Stack Overflow, so if you want the reputation you can answer there Smile

Thanks for your time!


Messages In This Thread
Cannot store chinese characters in MSSQL - by El Forum - 02-08-2012, 02:33 AM
Cannot store chinese characters in MSSQL - by El Forum - 02-08-2012, 02:43 AM
Cannot store chinese characters in MSSQL - by El Forum - 02-08-2012, 02:53 AM
Cannot store chinese characters in MSSQL - by El Forum - 02-08-2012, 04:19 AM
Cannot store chinese characters in MSSQL - by El Forum - 02-08-2012, 07:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB