CodeIgniter Forums
Special character insert into mssql - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Special character insert into mssql (/thread-55916.html)

Pages: 1 2


Special character insert into mssql - El Forum - 11-16-2012

[eluser]Juzt1s[/eluser]
Hello,

the problem I am facing is that when I insert special characters into mssql server I get
Code:
name ( 1.5 & # 4 1 ; , ie
istead of name (1.5), ie

What do I need to change to get normal values?

sorry for spaces


Special character insert into mssql - El Forum - 11-16-2012

[eluser]rebornishard[/eluser]
[quote author="Juzt1s" date="1353072947"]Hello,

the problem I am facing is that when I insert special characters into mssql server I get name (1.5), ie istead of name (1.5), ie

What do I need to change to get normal values?[/quote]

try to quote your post and i get (1.5 & # 4 1 ; not (1.5)
what encode you use on mssql ?


Special character insert into mssql - El Forum - 11-16-2012

[eluser]Juzt1s[/eluser]
I am using:
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';


Special character insert into mssql - El Forum - 11-16-2012

[eluser]rebornishard[/eluser]
[quote author="Juzt1s" date="1353074321"]I am using:
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';[/quote]
it's mssql right not mysql
mssql use utf16
so
$db['default']['char_set'] = 'utf16';
$db['default']['dbcollat'] = 'utf16_general_ci';

is that work ?


Special character insert into mssql - El Forum - 11-16-2012

[eluser]Juzt1s[/eluser]
It does not. Still a mess in databse column.

EDIT: I've check my dtabase collation, it's - SQL_Latin1_General_CP1_CI_AS


Special character insert into mssql - El Forum - 11-16-2012

[eluser]rebornishard[/eluser]
[quote author="Juzt1s" date="1353075356"]It does not. Still a mess in databse column.

EDIT: I've check my dtabase collation, it's - SQL_Latin1_General_CP1_CI_AS[/quote]
it's Latin1 try this
$db[‘default’][‘char_set’] = ‘latin1’;
$db[‘default’][‘dbcollat’] = ‘latin1_general_ci’;


Special character insert into mssql - El Forum - 11-16-2012

[eluser]Juzt1s[/eluser]
Does not work.


Special character insert into mssql - El Forum - 11-19-2012

[eluser]Juzt1s[/eluser]
Here is updated and more clear explanation:

The problem I am having is that when I get data out of database everything is fine, but when I write data with special symbols to database I get special symbols coded.

ex. When I write name (1.5), ie I get the name ( 1.5 & # 4 1 ; , ie (without spaces). But when I get from database base everything is fine and name (1.5), ie is shown.

The problem is that my search with special symbols does not work.

here are the configurations. database.config:

Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'xx.xx.x.xxx';
$db['default']['username'] = 'sa';
$db['default']['password'] = 'password';
$db['default']['database'] = 'database';
$db['default']['dbdriver'] = 'mssql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'latin1';
$db['default']['dbcollat'] = 'latin1_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
as you've noticed my database collation is SQL_Latin1_General_CP1_CI_AS.

I've tried setting values to:
Code:
$db[‘default’][‘char_set’] = ‘utf8’;
$db[‘default’][‘dbcollat’] = ‘utf8_general_ci’;

and:
Code:
$db[‘default’][‘char_set’] = ‘utf16’;
$db[‘default’][‘dbcollat’] = ‘utf16_general_ci’;

Any ideas how to write data with special symbols or have my search working. The search is simple, I get string, put it in SQL LIKE statement and return the values.


Special character insert into mssql - El Forum - 11-19-2012

[eluser]Narf[/eluser]
I suppose you've already read the answer to that question on StackOverflow, but here it is again:

Code:
@ini_set('mssql.charset', 'utf-8');



Special character insert into mssql - El Forum - 11-19-2012

[eluser]Juzt1s[/eluser]
I did. It works, but when it comes to () the stored value is & # 40; & # 41;