× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



from PHP I insert the string " ci·ré " into an IBM i database table. The
text, with its characters, is stored correctly in the table. But then,
when I use PHP to read from the column, the text that returns has a number
of extra characters at the end of the string. How to read this field
correctly?

here is how the text I read displays in the browser:

ci·ré @�
when I use DSPPFM to display the data as it is stored it displays
correctly:
ci·ré and the hex codes: 8389 B3995140 40404040

the table was created using SQL. The CCSID of all the columns is 37.

here is the PHP. I am even using utf8_encode to convert from ascii to
utf8.

<?php

header("Content-type: text/html");
$collNum = isset($_GET["collNum"]) ? $_GET["collNum"]: '' ;
$libl = isset($_GET["libl"]) ? $_GET["libl"]: '' ;

echo $collNum . '<br>' ;
echo $libl . '<br>' ;

$sql = 'select a.collnum, a.styles from prugcoll a ' .
'where a.collnum = ?' ;

$options = array('i5_naming' => DB2_I5_NAMING_ON);
$options['i5_libl'] = 'couri7' ;
$conn = db2_connect("*LOCAL","","", $options);

$stmt = db2_prepare($conn, $sql) ;

db2_bind_param( $stmt, 1, "collNum", DB2_PARAM_IN ) ;

$result = db2_execute($stmt) ;
while( $row = db2_fetch_array( $stmt ))
{
$rt_collNum = $row[0];
$styles = $row[1] ;
$utf8_styles = utf8_encode($styles);

echo '<p>COLLNUM:' . $rt_collNum . '</p>' ;
echo '<p>STYLES:' . $styles . '</p>' ;
echo '<p>length STYLES:' . strlen(trim($styles)) . '</p>' ;
echo '<p>utf8 encoded STYLES:' . $utf8_styles . '</p>' ;
}

?>

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.