I am using Codeigniter email library.
I have some data in serbian in database with this type of characters : žčćšđ
When I print it out in other palces, there is all OK with characters, so databese save it on right way.
My controller looks like this:
$config['charset'] = 'utf-8';
$this->load->library('email');
$this->email->initialize($config);
foreach($email as $val):
$this->load->library('email');
$this->email->from('rs#svstara.rs', 'Vojvođanska Svaštara - Mali Oglasi');
$this->email->to('daniela.stevanovic#gmail.com');
$this->email->subject($uid);
$this->email->message($tekst);
$this->email->send();
$info=$this->email->print_debugger();
endforeach;
echo json_encode(array('info'=>$info));
When I recieve email it looks lik this: pšđpšđpšđpšđ-čć.-
So there is some characters, what is not encoded.
you have to encode strings to UTF-8, even if you expect they are already utf-8 encoded. Try php mb-convert-encoding
mb_convert_encoding($content, "UTF-8");
Check that the file format is UTF-8 too. Sometimes, when using Eclipse, it sets by default to ISO-8859.
Right click on the file > Porperties > Text file encoding: UTF8.
You can apply this to all the project (WARNING: it may break up some characters)
Related
I would like to send my file to the client (like android side) as a hash string(like base64 or any encryption).
But I don't how can I read my file on my host.
for example URL of my file is:
example.com/assets/videos/test.mp4
You can crypt a file or String like this:
$encrypted = Crypt::encryptString('example.com/assets/videos/test.mp4');
And you can decrypt it like this:
$decrypted = Crypt::decryptString($encrypted);
Do not forget to use this at the header:
use Illuminate\Support\Facades\Crypt;
For more information I would recommend checking out the docs
I have a csv file on the server encoded as ANSI, and want to open it, process and save the content on the database.
I'm having infinite problems with the accented character as "à è ì ò ù", getting instead "?".
The content in the html header is set as utf-8.
This is my code
Response.CharSet = "UTF-8"
...
Set objStream = CreateObject("ADODB.Stream")
objStream.Type = 2
objStream.CharSet = "utf-8"
objStream.Open
objStream.Position = 0
objStream.LoadFromFile( path )
strData = objStream.ReadText()
Response.write(strData) '<== just to see
objStream.Close
Set objStream = Nothing
At first I was using a single FileSystem object, but read that it has even more problems handling encoding
Internally, VBScript strings are UTF-16 encoded. IO functions that read must be told/assume per default the correct source encoding to convert the source into UTF-16. IO function that write must be told/assume per default the desired output encoding to convert UTF-16 into that desired encoding.
If your file is really (some kind of) ANSI then your
objStream.CharSet = "utf-8"
is wrong. It should be the name of the encoding (cpXXX, ISO_YYY, ZZZ) that your file really uses.
Did you test using the FileSystemObject? Maybe it will guess right and your problem is solved without extra effort.
On one of our ColdFusion 10 enterprise / CentOS 6.5 servers umlauts in filenames are saved as ?.
For example:
<CFPROCESSINGDIRECTIVE pageencoding="UTF-8">
<CFSET VARIABLES.umlauts = "ümläüté" />
<CFSET VARIABLES.filename = createUUID() & "-" & VARIABLES.umlauts & ".txt" />
<CFFILE action="write" output="#VARIABLES.umlauts#" file="#expandpath("./" & VARIABLES.filename)#" />
<CFOUTPUT>#VARIABLES.filename#</CFOUTPUT> <!--- outputs something like: A9C9BC8C-983A-5EA6-A4ED411BA0E63C72-ümläüté.txt --->
writes a file called A8B49720-020A-2500-605F4CC73129D07C-?ml??t?.txt to disk. The content of the file is like expected "ümläüté".
Manual creating files with umlauts in filename is no problem (e.g. touch äöüß.txt works like expected).
More details of server:
Java Version: 1.6.0_29
Tomcat Version: 7.0.23.0
Java File Encoding: UTF8
$ cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
$ locale
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=
Any ideas what could cause this behaviour?
I'll put it out as an answer for more clear visibility.
A user of Open Blue Dragon (an alternative CFML Engine) was having exactly the same issue.
If I try to upload a file with, for example, the filename "testätest.pdf", then I have the following situation:
The file, OpenBD stores to my filesystem, is named: test?test.pdf
The filename, reported via #cffile.ServerFile# is: testätest.pdf
He later came back with this answer
It seems like this has been resolved by setting "LC_ALL=en_US.UTF-8". It seems to be a tomcat problem that it sets question marks for special characters if the charset is unknown.
Or, in the OP's case, to set LC_All to "de_DE.UTF-8" perhaps.
Source: Issue 516: Special characters (like german "Umlauts") in filenames of uploaded files are replaced with "?"
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.
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.