|
Posted by Chung Leong on 01/25/06 08:18
ralphie wrote:
> hi all
>
> since nearly 2 days i fight with mssql and utf-8 as i need to store and
> retrieve arabic characters.
>
> i tried the com approach
>
> http://groups.google.com/group/mailing.www.php-dev/browse_thread/thread/69f90dc978763e99/d61aa0bd48de23f0?lnk=st&q=php+mssql+utf-8&rnum=7#d61aa0bd48de23f0
>
> i tried as well the odbtp library, odbc and obviously the mssql native
> extension.. but i never succeded so far to store utf-8 data in the
> mssql server (column type nvarchar). if anybody has an idea, an
> approach or thinks he knows what i might have done wrong.. it is all
> highly appreciated.
>
> ou yes the content type is specified as follows in the document
>
> <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
>
> cheers ralphie
At work, we also have to deal with the Arabic script on a daily basis
and we also happen to use MSSQL. I have found is that there's no good
way to make use of the nvarchar, ntext column type. Maybe there's a
secret knob somewhere. I didn't find it in any event. So what we do is
just store the text as UTF-8 in regular varchar and text columns.
Varchar columns are a bit problematic, since you risk chopping a
character in half when truncation happens. Retrieving varchar columns
wider than 255 is also somewhat tricky using the extension (COM on the
other hand, leaks memory). So we usually use a text column when there
is no natural limit on text length.
MSSQL will sometimes complain when you put a UTF-8 string into a query
because it doesn't think that what you have is valid text. What you
have to do is just CONVERT() or CAST() to force it to accept the
string.
Navigation:
[Reply to this message]
|