Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nvarchar should show chinese and russian chars

Status
Not open for further replies.

kaiberlin

Programmer
Joined
Mar 11, 2005
Messages
4
Location
DE
Ich have a MSSQL table with a NVARCHAR field. There are values from different languages:

phptab.jpg


I just want to see these values in my browser.
I chose UTF-8 as charste:
Code:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

I tried direct access by php:


Code:
	$msconnect = mssql_connect($dbhostname, $dbuser, $dbpassword) ;
	$db = mssql_select_db($dbname, $msconnect) OR die ("Fehler bei mssql_select_db");
	$select = "SELECT * FROM $dbname.$dbowner.tblTest";
	$result = mssql_query ($select);
		
	while( $row = mssql_fetch_array($result))
	{
		printf("%s - %s<br>",$row["id"],$row["xtext_nvc"]);
	}

and all I see are uqestion marks instead of russian or chinese characters.

I also tried access using ODBC or ADO. But it didn't work, too.

Thank you very much,
Kai
 
turn off the default charset in your php.ini file (by using an empty string.

Code:
default_mimetype = "text/html"
default_charset = ""
 
Thanks for this hint. But it has no effect.

Kai
 
what character set are you using in the mssql db?
 
It is Latin1_General (Windows Collaction)
 
why not set the charset to utf8. there could well be something going awry with the data return.
 
I finally did it with ADODB.
There you can change the Codepage for the connection:

Code:
$dsn = "DRIVER={SQL Server};SERVER=$dbhostname;DATABASE=$dbname;UID=$dbuser;PWD=$dbpassword";

$conn = new COM("ADODB.Connection",NULL,CP_UTF8) or die("Cannot start ADO");
Thank you,jpadie, for your help,
Kai
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top