1

I'm in the process of converting LaTeX to MathML in PHP. texmath is the command line tool through which the conversion process can be done.

Latex file:

\mathbf{f} = (f_{1},
f_{2})^{\prime}

test.php:

shell_exec('echo "password" | sudo -S /root/.cabal/bin/texmath latexfile > outputfile');

If I run this PHP file through the command line, it generates the desired output file which is below.

Command line: php test.php

 <math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
  <mrow>
    <mstyle mathvariant="bold">
      <mi>𝐟</mi>
    </mstyle>
    <mo>=</mo>
    <mo stretchy="false" form="prefix">(</mo>
    <msub>
      <mi>f</mi>
      <mn>1</mn>
    </msub>
    <mo>,</mo>
    <msub>
      <mi>f</mi>
      <mn>2</mn>
    </msub>
    <msup>
      <mo stretchy="false" form="postfix">)</mo>
      <mo>′</mo>
    </msup>
  </mrow>
</math>

When I run this PHP file through the browser I am getting an output file like this:

<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
  <mrow>
    <mstyle mathvariant="bold">
      <mi>

It ignores all the mathtype characters. Why is it gives desired output only through the command line but not through the browser? When I open these two files in the editor it displays 'UTF-8'. Is this a character encoding issue? How do I solve this?

1

This is I suspect mostly off topic for this site. The bold f you show is

U+1d41f MATHEMATICAL BOLD SMALL F

Which is the right character. As posted on this web site it is correctly encoded and served as UTF-8 encoded data but we can't tell what your web server is doing.

Make sure the php file is serving the data as utf-8 not iso-8859-1 or any other encoding. PHP questions are definitely off topic here so if you need help with that you could use the php tag on stack overflow.

Not the answer you're looking for? Browse other questions tagged or ask your own question.