<meta charset="windows-874">
<?
$link = mssql_connect('192.168.0.20', 'sa', 'ufida');
mssql_select_db('UFDATA_009_2012', $link);
// sending data to database
$utf8 = 'some unicode windows-874 data'; // some Greek text for example ;)
$ucs2 = iconv('gb18030', 'windows-874', $utf8);
$arr = unpack('H*hex', $ucs2);
$hex = "0x{$arr['hex']}";
$result = mssql_query("select convert(nvarchar(100), cInvCName) from InventoryClass", $link);
while (($row = mssql_fetch_array($result, MSSQL_BOTH)))
{
// we get data in UCS-2
// I use UTF-8 in my project, so I encode it back
echo(iconv('gb18030', 'windows-874', $row['cInvCName']));
}
mssql_free_result($result);
mssql_close($link);
?>
ไม่ว่าจะ charset="อะไรก็ไม่ได้นะครับ"
ล่าสุดผ่าน ODBC มาที่ Microsoft ทั้งหลายก็เป็นภาษาไทยครับ
<meta charset="windows-874">
<?
$link = mssql_connect('192.168.0.20', 'sa', 'ufida');
mssql_select_db('UFDATA_009_2012', $link);
// sending data to database
$utf8 = 'some unicode windows-874 data'; // some Greek text for example ;)
$ucs2 = iconv('gb18030', 'windows-874', $utf8);
$arr = unpack('H*hex', $ucs2);
$hex = "0x{$arr['hex']}";
$result = mssql_query("select convert(nvarchar(100), cInvCName) from InventoryClass", $link);
while (($row = mssql_fetch_array($result, MSSQL_BOTH)))
{
// we get data in UCS-2
// I use UTF-8 in my project, so I encode it back
echo(iconv('gb18030', 'windows-874', $row['cInvCName']));
}
mssql_free_result($result);
mssql_close($link);
?>