2

I have a windows IIS server working with PHP. The user inserts a word via an HTML form, it goes to PHP and then PHP calls a COM dll (vb6) function passing the word to the function as a utf8 string.

Everything goes fine, until an input contains capital Greek letters with dialytika such as http://unicode-table.com/en/03AA/

When that happens, a PHP warning comes telling me: [07-Jul-2016 14:15:50 Europe/Athens] PHP Warning: Unknown: Could not convert string to unicode: No mapping for the Unicode character exists in the target multi-byte code page. and a different scrambled string passes.

for example, the word μαϊου will work fine but the word μαΪου will produce the warning.

here is what the .dll function sees in both cases: enter image description here

I tried playing with php settings a bit, but nothing changed. Current settings for php.ini (the ones I changed from default to the following ones - but still nothing):

default_charset = "utf-8"
com.code_page="utf-8"
mbstring.internal_encoding = UTF-8

I'm not sure what I must do to fix this issue. Thank you in advance for any insight.

MirrorMirror
  • 105
  • 2
  • 11
  • That's indeed a strange one, as both chars are in the same unicode block and have a 2-byte-length ... I couldn't replicate any problem with this chars on my local PHP installation. Maybe you can work around the problem, through base64 encoding the string for the transfer? Sorry for not being very helpful. ;-) – s1lv3r Jul 07 '16 at 12:48
  • 1
    Please consider sharing a code snippet where _PHP calls a COM dll (vb6) function passing the word to the function as a utf8 string_ (do you call a common _dll_ or home-made one?). Moreover: as far as possible, please prefer to post data in code snippets instead of images. Your example shows `ϊ` _Greek Small Letter Iota With Dialytika_ in `μαϊου` (UTF-8 byte sequence `206`,`138`) but byte sequence `206`, `144` shown in image is UTF-8 representation of `ΐ` _Greek Small Letter Iota With Dialytika And Tonos_. – JosefZ Aug 18 '16 at 19:34

1 Answers1

2

I resolved this by specifying the codepage when instantiating the com object. I could never get it working using the php.ini com.code_page directive. Try using:

$com = new COM("object name", NULL, CP_UTF8);
Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
billm
  • 21
  • 2