Page 1 of 1

cannot convert from ASCII ->UTF-8

Posted: Tue Jun 09, 2009 3:22 am
by zoftdev
Using mb_convert_encoding or utf8_encode but ASCII never change to UTF-8,
checking by md5 still get same result.

caller:
$tmp=fixEncoding($tmp);
$tmp=fixEncoding($tmp);
$tmp=fixEncoding($tmp);

function:

Code: Select all

 
function fixEncoding($in_str)
{
  $cur_encoding = mb_detect_encoding($in_str) ;
  if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))
  {
    debug("no utf-8 convert");
    return $in_str;
  }
  else {
    debug("converted! from ".$cur_encoding);
    //return utf8_encode($in_str);
    return mb_convert_encoding($in_str,"UTF-8","auto");
    }
} // fixEncoding 
 

Result:
debug: converted! from ASCII

debug: converted! from ASCII

debug: converted! from ASCII
PHPINFO:

Code: Select all

 
System  Windows NT HLEX 5.1 build 2600
Build Date  Dec 8 2008 19:30:48
Configure Command   cscript /nologo configure.js "--enable-snapshot-build" "--enable-debug-pack" "--with-snapshot-template=d:\php-sdk\snap_5_2\vc6\x86\template" "--with-php-build=d:\php-sdk\snap_5_2\vc6\x86\php_build" "--with-pdo-oci=D:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=D:\php-sdk\oracle\instantclient10\sdk,shared"
Server API  Apache 2.0 Handler
Virtual Directory Support   enabled
Configuration File (php.ini) Path   C:\WINDOWS
Loaded Configuration File   G:\xampp\apache\bin\php.ini
Scan this dir for additional .ini files     (none)
additional .ini files parsed    (none)
PHP API     20041225
PHP Extension   20060613
Zend Extension  220060519
Debug Build     no
Thread Safety   enabled
Zend Memory Manager     enabled
IPv6 Support    enabled
Registered PHP Streams  php, file, data, http, ftp, compress.zlib, https, ftps, zip
Registered Stream Socket Transports     tcp, udp, ssl, sslv3, sslv2, tls
Registered Stream Filters   convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*
 
 
Environment
Variable    Value
ALLUSERSPROFILE     C:\Documents and Settings\All Users
CommonProgramFiles  C:\Program Files\Common Files
COMPUTERNAME    HLEX
ComSpec     C:\WINDOWS\system32\cmd.exe
DEFLOGDIR   C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
FP_NO_HOST_CHECK    NO
JDEV_USER_DIR   G:\doc\job\jdevWork\_CONFIG
NUMBER_OF_PROCESSORS    2
OPENSSL_CONF    C:\OpenSSL\bin\openssl.cfg
OS  Windows_NT
Path    C:\j2sdk1.4.2_18\bin;c:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\80\Tools\BINN
PATHEXT     .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE  x86
PROCESSOR_IDENTIFIER    x86 Family 6 Model 23 Stepping 6, GenuineIntel
PROCESSOR_LEVEL     6
PROCESSOR_REVISION  1706
ProgramFiles    C:\Program Files
SystemDrive     C:
SystemRoot  C:\WINDOWS
TEMP    C:\WINDOWS\TEMP
TMP     C:\WINDOWS\TEMP
USERPROFILE     C:\Documents and Settings\NetworkService
VS80COMNTOOLS   C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\
VSEDEFLOGDIR    C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
WF_RESOURCES    c:\oracle\ora92\WF\RES\WFus.RES
windir  C:\WINDOWS
AP_PARENT_PID   4796
 
PHP Variables
Variable    Value
_REQUEST["rating"]  200905131152070690041253
_COOKIE["rating"]   200905131152070690041253
_SERVER["HTTP_HOST"]    localhost
_SERVER["HTTP_USER_AGENT"]  Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10
_SERVER["HTTP_ACCEPT"]  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
_SERVER["HTTP_ACCEPT_LANGUAGE"] en-us,en;q=0.5
_SERVER["HTTP_ACCEPT_ENCODING"] gzip,deflate
_SERVER["HTTP_ACCEPT_CHARSET"]  TIS-620,utf-8;q=0.7,*;q=0.7
_SERVER["HTTP_KEEP_ALIVE"]  300
_SERVER["HTTP_CONNECTION"]  keep-alive
_SERVER["HTTP_REFERER"] http://localhost/xampp/navi.php
_SERVER["HTTP_COOKIE"]  rating=200905131152070690041253
_SERVER["PATH"] C:\j2sdk1.4.2_18\bin;c:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\80\Tools\BINN
_SERVER["SystemRoot"]   C:\WINDOWS
_SERVER["COMSPEC"]  C:\WINDOWS\system32\cmd.exe
_SERVER["PATHEXT"]  .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
_SERVER["WINDIR"]   C:\WINDOWS
_SERVER["SERVER_SIGNATURE"] <address>Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.8 Server at localhost Port 80</address>
_SERVER["SERVER_SOFTWARE"]  Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i mod_autoindex_color PHP/5.2.8
_SERVER["SERVER_NAME"]  localhost
_SERVER["SERVER_ADDR"]  127.0.0.1
_SERVER["SERVER_PORT"]  80
_SERVER["REMOTE_ADDR"]  127.0.0.1
_SERVER["DOCUMENT_ROOT"]    G:/doc/job/htdocs
_SERVER["SERVER_ADMIN"] admin@localhost
_SERVER["SCRIPT_FILENAME"]  G:/doc/job/htdocs/xampp/phpinfo.php
_SERVER["REMOTE_PORT"]  2970
_SERVER["GATEWAY_INTERFACE"]    CGI/1.1
_SERVER["SERVER_PROTOCOL"]  HTTP/1.1
_SERVER["REQUEST_METHOD"]   GET
_SERVER["QUERY_STRING"] no value
_SERVER["REQUEST_URI"]  /xampp/phpinfo.php
_SERVER["SCRIPT_NAME"]  /xampp/phpinfo.php
_SERVER["PHP_SELF"] /xampp/phpinfo.php
_SERVER["REQUEST_TIME"] 1244535549
_SERVER["argv"] 
 
Array
(
)
 
_SERVER["argc"] 0
_ENV["ALLUSERSPROFILE"] C:\Documents and Settings\All Users
_ENV["CommonProgramFiles"]  C:\Program Files\Common Files
_ENV["COMPUTERNAME"]    HLEX
_ENV["ComSpec"] C:\WINDOWS\system32\cmd.exe
_ENV["DEFLOGDIR"]   C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
_ENV["FP_NO_HOST_CHECK"]    NO
_ENV["JDEV_USER_DIR"]   G:\doc\job\jdevWork\_CONFIG
_ENV["NUMBER_OF_PROCESSORS"]    2
_ENV["OPENSSL_CONF"]    C:\OpenSSL\bin\openssl.cfg
_ENV["OS"]  Windows_NT
_ENV["Path"]    C:\j2sdk1.4.2_18\bin;c:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\80\Tools\BINN
_ENV["PATHEXT"] .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
_ENV["PROCESSOR_ARCHITECTURE"]  x86
_ENV["PROCESSOR_IDENTIFIER"]    x86 Family 6 Model 23 Stepping 6, GenuineIntel
_ENV["PROCESSOR_LEVEL"] 6
_ENV["PROCESSOR_REVISION"]  1706
_ENV["ProgramFiles"]    C:\Program Files
_ENV["SystemDrive"] C:
_ENV["SystemRoot"]  C:\WINDOWS
_ENV["TEMP"]    C:\WINDOWS\TEMP
_ENV["TMP"] C:\WINDOWS\TEMP
_ENV["USERPROFILE"] C:\Documents and Settings\NetworkService
_ENV["VS80COMNTOOLS"]   C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\
_ENV["VSEDEFLOGDIR"]    C:\Documents and Settings\All Users\Application Data\McAfee\DesktopProtection
_ENV["WF_RESOURCES"]    c:\oracle\ora92\WF\RES\WFus.RES
_ENV["windir"]  C:\WINDOWS
_ENV["AP_PARENT_PID"]   4796

Re: cannot convert from ASCII ->UTF-8

Posted: Tue Jun 09, 2009 4:04 am
by Apollo
Exactly what are you trying to do, or what do you want?

Regarding the topic title: ascii is, by definition, already utf8 (not vice versa).

Re: cannot convert from ASCII ->UTF-8

Posted: Tue Jun 09, 2009 4:28 am
by zoftdev
Apollo wrote:Exactly what are you trying to do, or what do you want?

Regarding the topic title: ascii is, by definition, already utf8 (not vice versa).
You mean md5("<xmltest/>") will get the same between ASCII & UTF-8 ?

Re: cannot convert from ASCII ->UTF-8

Posted: Wed Jun 10, 2009 3:55 am
by Apollo
zoftdev wrote:You mean md5("<xmltest/>") will get the same between ASCII & UTF-8 ?
md5 doesn't distinghuish between ascii or utf-8, it just treats the input as a piece of binary data and calculates its md5 hash.