ivankokan / Excel2LaTeX

The Excel add-in for creating LaTeX tables
Other
1.27k stars 147 forks source link

encoding #24

Open thorade opened 6 years ago

thorade commented 6 years ago

When saving a table to a tex file, that file has ANSI encoding, so if the table contains e.g. ÄÖÜ I currently need to open the file in Notepad++ and convert to UTF-8. Would it be possible to either store the file as UTF-8 directly, or convert Ö to {\"O} ??

I filed a similar issue years ago: https://bugs.launchpad.net/excel2latex/+bug/944134 but the workaround used there does not work anymore, because I switched from pdflatex to lualatex.

Any ideas for a new workaround or solution? By now all editors support UTF-8, and pdflates also supports utf8.

ma-harvey commented 6 years ago

I was facing the same issue and found a solution, simply by editing the saving function in the VBA editor.

Change the "SaveConversionResultToFile" as follows:

`Public Sub SaveConversionResultToFile(ByVal pModel As IModel) Dim sFileName As String sFileName = pModel.AbsoluteFileName If sFileName = "" Then Exit Sub

Dim fsT As Object
Set fsT = CreateObject("ADODB.Stream")
fsT.Type = 2 'Specify stream type - we want To save text/string data.
fsT.Charset = "utf-8" 'Specify charset For the source text data.
fsT.Open 'Open the stream And write binary data To the object
fsT.WriteText pModel.GetConversionResult
fsT.SaveToFile sFileName, 2 'Save binary data To disk

End Sub`

The result is that the file generated will be UTF-8 directly

thorade commented 6 years ago

Nice! Could you submit that as a Pull Request? And in the text, reference this issue as #24?

ma-harvey commented 6 years ago

I'm not so familiar with GitHub mechanics.

But feel free to post it.

ivankokan commented 5 years ago

@thorade Until PR gets accepted, you can use "Copy to Clipboard", right?

thorade commented 5 years ago

OK, thanks, will try that. ADOB.Streams does not work on Mac, it seems. What platforms did you test your PR on?

ivankokan commented 5 years ago

Windows 7, Office 365. Try to contribute for Mac :), maybe this will help: http://talesoftech.blogspot.com/2011/05/excel-on-mac-goodbye-vba-hello.html.

ivankokan commented 5 years ago

@thorade, if you are able to test #28 on Mac, can you please describe the behavior? Which error you exactly get (assuming that ADODB.Stream is not supported)? I would like to handle errors in that case, at least saying "This feature is not (yet) supported on Mac".

ivankokan commented 5 years ago

Hi @thorade, I am about to implement Unicode -> UTF-8 encoder on my own so it's platform independent. Stay tuned.