www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - The ANSI character set is very important for operating MSSQL,if no

reply "FrankLike" <1150015857 qq.com> writes:
The ANSI character set is very important for operating MSSQL, if 
no conversion, will expand the scope of D users, that can attract 


Now, the data comming from MsSql must convert by 'fromMBS' or 
'toMBSz',it's  not convenient to operate DataBase.

Do you think a string that named 'Astring' which means 'ANSI' 
string is good for D?

Thank you.
Jan 13 2015
next sibling parent Mike Parker <aldacron gmail.com> writes:
On 1/14/2015 1:47 AM, FrankLike wrote:
 The ANSI character set is very important for operating MSSQL, if no

 users.
Not likely.
 Now, the data comming from MsSql must convert by 'fromMBS' or
 'toMBSz',it's  not convenient to operate DataBase.

 Do you think a string that named 'Astring' which means 'ANSI' string is
 good for D?
This has nothing to do with ANSI, and everything to do with multibyte character sets. Besides which, there always must be a to/from something when converting between D strings and C strings, no matter what format the C string is in.
Jan 13 2015
prev sibling next sibling parent reply "Brad Anderson" <eco gnuk.net> writes:
On Tuesday, 13 January 2015 at 16:47:33 UTC, FrankLike wrote:
 The ANSI character set is very important for operating MSSQL, 
 if no conversion, will expand the scope of D users, that can 


 Now, the data comming from MsSql must convert by 'fromMBS' or 
 'toMBSz',it's  not convenient to operate DataBase.

 Do you think a string that named 'Astring' which means 'ANSI' 
 string is good for D?

 Thank you.
If by ANSI you mean codepage-1252 we actually have that in the frequently overlooked std.encoding. http://dlang.org/library/std/encoding/windows1252_string.html http://dlang.org/library/std/encoding/EncodingSchemeWindows1252.html
Jan 13 2015
parent "FrankLike" <1150015857 qq.com> writes:
On Wednesday, 14 January 2015 at 02:08:21 UTC, Brad Anderson 
wrote:
 On Tuesday, 13 January 2015 at 16:47:33 UTC, FrankLike wrote:
 The ANSI character set is very important for operating MSSQL, 
 if no conversion, will expand the scope of D users, that can 


 Now, the data comming from MsSql must convert by 'fromMBS' or 
 'toMBSz',it's  not convenient to operate DataBase.

 Do you think a string that named 'Astring' which means 'ANSI' 
 string is good for D?

 Thank you.
If by ANSI you mean codepage-1252 we actually have that in the frequently overlooked std.encoding. http://dlang.org/library/std/encoding/windows1252_string.html http://dlang.org/library/std/encoding/EncodingSchemeWindows1252.html
Thank you. I get data by arsd from MsSql,it can display string ok in cmd,but not work ok on gui.
Jan 13 2015
prev sibling parent reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Tuesday, 13 January 2015 at 16:47:33 UTC, FrankLike wrote:
 The ANSI character set is very important for operating MSSQL, 
 if no conversion, will expand the scope of D users, that can 

MSSQL supports UCS2 (16 bit unicode) for nvarchar and you should be able to set the connection to UTF-8.
Jan 14 2015
parent reply "FrankLike" <1150015857 qq.com> writes:
On Wednesday, 14 January 2015 at 13:44:39 UTC, Ola Fosheim 
Grøstad wrote:
 On Tuesday, 13 January 2015 at 16:47:33 UTC, FrankLike wrote:
 The ANSI character set is very important for operating MSSQL, 
 if no conversion, will expand the scope of D users, that can 

MSSQL supports UCS2 (16 bit unicode) for nvarchar and you should be able to set the connection to UTF-8.
' set the connection to UTF-8'? MSSQL? How to do? But I only know it ok in mySql. Thank you.
Jan 14 2015
parent reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Wednesday, 14 January 2015 at 15:37:20 UTC, FrankLike wrote:
 On Wednesday, 14 January 2015 at 13:44:39 UTC, Ola Fosheim 
 Grøstad wrote:
 On Tuesday, 13 January 2015 at 16:47:33 UTC, FrankLike wrote:
 The ANSI character set is very important for operating MSSQL, 
 if no conversion, will expand the scope of D users, that can 

MSSQL supports UCS2 (16 bit unicode) for nvarchar and you should be able to set the connection to UTF-8.
' set the connection to UTF-8'? MSSQL? How to do? But I only know it ok in mySql. Thank you.
Just search for it. https://www.google.no/?q=mssql%20connection%20utf-8 First hit: http://stackoverflow.com/questions/1322421/php-sql-server-how-to-set-charset-for-connection
Jan 14 2015
parent reply "FrankLike" <1150015857 qq.com> writes:
On Wednesday, 14 January 2015 at 15:56:14 UTC, Ola Fosheim 
Grøstad wrote:
 On Wednesday, 14 January 2015 at 15:37:20 UTC, FrankLike wrote:
 On Wednesday, 14 January 2015 at 13:44:39 UTC, Ola Fosheim 
 Grøstad wrote:
 On Tuesday, 13 January 2015 at 16:47:33 UTC, FrankLike wrote:
 The ANSI character set is very important for operating 
 MSSQL, if no conversion, will expand the scope of D users, 

MSSQL supports UCS2 (16 bit unicode) for nvarchar and you should be able to set the connection to UTF-8.
' set the connection to UTF-8'? MSSQL? How to do? But I only know it ok in mySql. Thank you.
Just search for it. https://www.google.no/?q=mssql%20connection%20utf-8 First hit: http://stackoverflow.com/questions/1322421/php-sql-server-how-to-set-charset-for-connection
Not a good idea.
Jan 14 2015
parent reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Wednesday, 14 January 2015 at 16:44:35 UTC, FrankLike wrote:
 Not  a  good  idea.
What is not a good idea? The default collation differs based on the OS settings AFAIK. In western countries it probably is ISO8859-1 (not a windows code page, but close). Unicode data is UCS2LE (little endian), but if you get the settings right the client library should allow you to use UTF-8.
Jan 14 2015
parent reply "FrankLike" <1150015857 qq.com> writes:
On Wednesday, 14 January 2015 at 17:19:42 UTC, Ola Fosheim 
Grøstad wrote:
 On Wednesday, 14 January 2015 at 16:44:35 UTC, FrankLike wrote:
 Not  a  good  idea.
What is not a good idea? The default collation differs based on the OS settings AFAIK. In western countries it probably is ISO8859-1 (not a windows code page, but close). Unicode data is UCS2LE (little endian), but if you get the settings right the client library should allow you to use UTF-8.
The wstring displayed ok in cmd,but not ok in gui(must use the fromMBS fuction),so I want to test change the gui'control.d ,set text property is Tstring ,by verstion(ANSI),set text is wstring ,else ,set text is string.
Jan 15 2015
parent reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Thursday, 15 January 2015 at 14:50:29 UTC, FrankLike wrote:
 The wstring displayed ok in cmd,but not ok in gui(must use the 
 fromMBS fuction),so I want to test change the gui'control.d 
 ,set text property is Tstring ,by verstion(ANSI),set text is 
 wstring ,else ,set text is string.
Ah, ok. Just keep in mind that if you see missing characters it might be the configuration of your client library that is the problem since newer versions of MSSQL should use UCS2 during transfer. Some libraries convert to less capable character sets such as iso-8859-1 by default. I believe each varchar column in the database can have a different character set since the database scheme can specify the collation, but nvarchar columns use UCS2. It is generally a good idea to look over your schema and see what is specified if you cannot support unicode.
Jan 15 2015
parent "FrankLike" <1150015857 qq.com> writes:
On Thursday, 15 January 2015 at 16:03:47 UTC, Ola Fosheim Grøstad 
wrote:
 On Thursday, 15 January 2015 at 14:50:29 UTC, FrankLike wrote:
 The wstring displayed ok in cmd,but not ok in gui(must use the 
 fromMBS fuction),so I want to test change the gui'control.d 
 ,set text property is Tstring ,by verstion(ANSI),set text is 
 wstring ,else ,set text is string.
Ah, ok. Just keep in mind that if you see missing characters it might be the configuration of your client library that is the problem since newer versions of MSSQL should use UCS2 during transfer. Some libraries convert to less capable character sets such as iso-8859-1 by default. I believe each varchar column in the database can have a different character set since the database scheme can specify the collation, but nvarchar columns use UCS2. It is generally a good idea to look over your schema and see what is specified if you cannot support unicode.
I use it :https://github.com/adamdruppe/arsd/blob/master/mssql.d Sorry,I test again, find string displayed ok in 'mssql db' and cmd ,but not ok in gui(must use the fromMBS fuction). And I test charset=UCS2,get error:invalid UTF-8 Exception. Insert data:2 words string("中文") can insert,and display ok in gui,but wstring not work,and 3 words string("中文了") stop work. If insert string("中文") ,display not ok in db,but ok in cmd and gui.
Jan 16 2015