Using PHPEXCEL with UTF-8 results in error messages - utf-8

When I create an Excel Sheet with PHPEXCEL based on the "01simple-download-xlsx.php" example, I will get an error message in Excel as I am using UTF-8.
The error message says "Excel cannot open the file because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file." I've used the 01simple-download-xlsx.php Testfile and tried to change the $objWriter to the one out of the 26utf8.php Testfile... both didnt work...
So how can I prevent this error and create a proper UTF-8 compatible Excel file with PHPEXCEL?

The reason was:
I have saved my php files with notepad in UTF-8 format. Therefor it was saved with the UTF-8 BOM. I have reopened the files in Notepad++ and saved the files as UTF-8 Without BOM. This way the Excel file gets generated correctly.

Related

ffmpeg unknown keyword invalid data found when processing input

I have a file ffmpeg_list_of_files.txt with the content
file '.\Output_0\forces_vs_radii.pdf'
file '.\Output_1\forces_vs_radii.pdf'
file '.\Output_2\forces_vs_radii.pdf'
file '.\Output_3\forces_vs_radii.pdf'
file '.\Output_4\forces_vs_radii.pdf'
and so on...
and then run ffmpeg -f concat -i ffmpeg_list_of_files.txt -c copy output.mkv as is stated at
http://trac.ffmpeg.org/wiki/Concatenate
I, unfortunately, get the error
Line 1: unknown keyword ' ■f'
.\ffmpeg_list_of_files.txt: Invalid data found when processing input
in Windows PowerShell in Windows 10.
What am I doing wrong?
It's an encoding problem I also got that I solved changing the file encoding.
Steps to solve it:
Open the ffmpeg_list_of_files.txt with the notepad, notepad++ or similar
Change the encoding to UTF-8 without BOM. To do it follow one of the next steps:
with windows notepad, this is done using the "save as..." option and at the bottom changing the encoding to "UTF-8" and press "save"
with notepad++ select "encoding" in the main menu and select "encoding with UTF-8 without BOM" and save the file after that
Names could change a little bit depending on the version, but following the steps it's pretty straight forward.
Note: In my case, when redirecting ls or dir to a file in powershell, the default encoding of the file is USC-2

How do I properly unzip a zip with Chinese character that from Windows in OSX?

One day I just zipped a file with Chinese character called 周國賢 - 密封罩.flac, to a zip, using bandizip & designated encoding to utf-8.
And then I try to unzip it in my MacbookPro, which is (probably) using Macintosh as encoding. The file unzipped is called ©P∞ÍΩ - ±K´ ∏n.flac, which does not match the above Chinese name.
So, I try to test about the encoding, and found that Macintosh->big5 would return the Macintosh mysterious symbol into Cantonese, but have some unmatching characters: 周衰�璀� - 密封罩.flac.
I have tried another file: §˝µ· - ¨ı®ß.ape: and it actually output the correct name of the file: 王菲 - 紅豆.ape
So, here is my question: how do I unzip a file that with big5 chinese character properly and without any information loss? Or how do I zip a file correctly to prevent information loss/ incorrect characters? (edit #2: you can use bandizip to zip the file into utf-8 encoding)
BTW, The encoding converter I am using is https://r12a.github.io/apps/encodings/, which could be quite helpful for you to check for encoding. Don't forget to click change encodings shown. And I am not the owner of the encoding converter.
edit #1: I have found that the setting in bandizip is wrong...well sorry for the inconvenience caused. Nonetheless, I figure out that The Unarchiver in Mac Apple Store can unzip big5 correctly. This can be a workaround, but still I don't know how to unzip big5 characters properly WITHOUT any loss.

Ruby CSV incorrect first character

I have an xlsx file, I do the following to export it as a .csv :
Export xlsx file as csv using excel, default encoding
Open .csv file with notepad, save it again by specifying the encoding utf8 (notepad saves the BOM)
Open the file with CSV.read(path_to_file)
It seems to work well, but for some reason the first header is corrupted by some unknown character (I have no idea what it is, and when I try to copy paste it it disappears, it is represented as a big white rectangle in Windows)
When I open my file with any text editor, there doesn't seem to be a problem
First line looks like : Id;Type....
In case this helps
csv.headers.first # => ".Id" where . is that character
csv.headers.first.first.bytes # => [239, 187, 191]
csv.headers.first.first.b # => "\xEF\xBB\xBF"
How do I fix that ?
Windows 10, Ruby 2.2
That is the UTF-8 BOM.
Try setting the mode like this:
CSV.read(path_to_file, 'r:bom|utf-8')

TIBCO BW: Read Resource file using "Read File" or "Parse Data" activities

I have a txt file inside the resource folder of my BW project.
I have need to read that file using "Read File" or "Parse Data" activities.
These activities require me to specify the location of the file.
What is the location of the resource file, that I could use as the file spec of "Read File" or "Parse Data" activities?
Let's say my txt file is /Resources/Policy.txt, in my BW project.
If my project is UTF-8 enconding, would the encoding of that file also be UTF-8?
You can read the content of the file with the "retrieve resource" activity. If you put in your relative project path "/Resources/Policy.txt", it gives you back the content of the file (base64 encoded).
With that you can decode the content and work from that point onwards.
regarding 1) use "retrieve resources" instead of "read file" and you should be fine.
regarding 2) the project encoding should have no influence of the encoding of you text file. You have to manage the encoding on you own and implement it through the base64 decode after retrieving the content.

UTF-8 i18n file

I'm trying to add a Chinese localisation to a scaffolded Yesod site. I have a zh.msg message file saved as UTF-8 format using Notepad in Windows, but when I run cabal install in the project directory, I get this:
Handler\Home.hs:15:11:
Not in scope: data constructor `MsgHello'
Perhaps you meant `Msg<stderr>: hPutChar: invalid argument (invalid character)
The line in question is where I render my homepage:
$(widgetFile "homepage")
I changed both message files to be Unicode formatted instead of UTF-8, and get this message instead:
Foundation.hs:1:1:
Exception when trying to run compile-time code:
Cannot decode byte '\xff': Data.Text.Encoding.Fusion.streamUtf8: invalid UTF-8 stream
So I guess UTF-8 is the way to go... somehow.
(I'm using Notepad because I haven't set up gVim to render Unicode characters. It's apparently a bit of a feat.)
When I went to commit my changes I discovered the issue. The diff for my English file looked like this:
-Hello: Hello
+<U+FEFF>Hello: Hello
I guess notepad added the character in, and it was working its way into the Haskell code. I solved it using vim according to this answer.

Resources