I'm using Maatwebsite excel v ~2.1.0 for my Laravel 5.2 project. My problem is that the japanese characters are not rendered as seen the photo below. As you can see, I have 23 heading rows and the displayed data only are only English characters. Columns that uses Japanese characters are null.
This is my data in my CSV file.
This is my approach in loading the CSV file:
Excel::load(request()->file('file'), function($reader) {
$results = $reader->all();
dd($results);
});
What should I change to make the Japanese characters readable?
Okay after exploring more, I found out the answer. In excel.php file, I changed 'to_ascii' => true, to 'to_ascii' => false and my problem is fixed. Hope this helps someone in the near future.
Related
I use 'use_bom' => true to read Japanese in CSV files when opening with Excel. I call through postman everything is fine, but when I call the API via FE, I get a Japanese font error.
I tried changing the content-type content-encode in the header, but it doesn't seem to work.
I tried searching with the keyword "bomb csv" and I did the following
before
href={data:text/csv;charset=utf-8,${encodeURIComponent(dataCSV,)}}
after
href={data:text/csv;charset=utf-8,${encodeURIComponent('\uFEFF' + dataCSV,)}}
so the returned csv file does not have font errors anymore. I don't understand why but glad I fixed it anyway
I'm making English-Spanish website so depending the language I have to give the user different strings. To do it I'm using Laravel's trans() function.
The problem is that in Blade the trans() outputs html entity encoded characters.
So for example when I put {{ trans('messages.title') }} which points to the string
'title' => 'Título' in the lang file, instead of Título I have Título.
But if I just have the string (or character) put directly in the file it is shown normally.
Is this normal in Laravel 5.2 that trans() function outputs htmlentity encoded string instead of normal UTF8 character?
If not any idea what I'm doing wrong?
If yes is it possible to output normal characters instead?
I have found out that when I use #lang() instead of {{ trans() }} it gives me the character.
So it looks like this is how it works.
But if there is anybody who knows and can confirm that this behavior is intentional and correct, that would be great.
How to implement internationalization in angularjs?
How to achieve multi language support including numeric(0 - 9) and all the special characters like - .,#$& etc. in angularjs application?
For exapmle - Suppose user has selected Chinese as the preferred language from application settings.
So I need to display him numeric data eg - $123,23.01 in Chinese.
Also here in $123,23.01 after $123 I have comma(,) but in Chinese the separator like comma(, and .) are different.
If anyone could share fiddle link of working copy or any clue, it will be a great help.
Thank you .. :)
I could solve it using JavaScript's native method number.toLocalString.
var number = 123456.789;
// request a currency format
console.log(number.toLocaleString('de-DE', { style: 'currency', currency: 'EUR' }));
// → 123.456,79
€
I'm doing the following to create a label that I use as part of attribution for a photo:
CCLabelTTF *imageSourceLabel = [CCLabelTTF labelWithString:[_organism imageSource] fontName:[[UIFont systemFontOfSize:12] fontName] fontSize:12];
Several of the image sources include Turkish letters. For example, in this URL:
http://commons.wikimedia.org/wiki/File:Şahlûr-33.jpg
This displays improperly in my iPad app; the Turkish letters are missing.
How do I create a label that will work with text like that in the URL above?
Edit:
Nevermind... the problem is with exporting from Excel. See the comments on the answer below. This link provides some additional information: Excel to CSV with UTF8 encoding
Additional Edit:
Actually, it's still a problem, even after I export correctly and verify that I have the proper UTF-8 (or is it 16?) letters in the CSV file. For example, this string:
Dûrzan cîrano / CC BY-SA 3.0
Is displayed like this:
and this string:
Christian Mehlführer / CC-BY 2.5
is displayed like this:
It's definitely being processed improperly upon import, as CCLOG generates the following:
Photo Credit: Dûrzan cîrano / CC BY-SA 3.0
More Info:
Upon import, I'm storing the following value as a string in an array:
"Christian Mehlf\U00c3\U00bchrer / CC-BY 2.5"
Wikipedia says the UTF-8 value for ü, in hex, is C3 BC. It looks like the c3bc is in there, but masked as \U00c3\U00bc.
Is there any way to convert this properly? Or is something fundamentally broken at the CSV import level?
The solution is below.
There were several problems:
Excel on the Mac doesn't export UTF-8 properly. The solution I used was to paste the data into Google Spreadsheet and export from there. More info here: Excel to CSV with UTF8 encoding
I realized that once I had the proper data in the CSV file, that I was importing it with the improper settings. I'm using parseCSV and needed to set _encoding in the -init method to NSUTF8StringEncoding instead of the default, NSISOLatin1StringEncoding.
if you try this:
[CCLabelTTF labelWithString:[[_organism imageSource] stringByUnescapingHTML] fontName:[[UIFont systemFontOfSize:12] fontName] fontSize:12];
it will likely work better. I suspect your url string is escaped HTML.
I have my database results (áéíóúàâêô...) and when I display any of this characters I get codes like:
á
My controller is like this:
ViewBag.EstadosDeAlma = (from e in db.EstadosDeAlma select e.Title).ToList();
My cshtml page is like this:
var data = '#foreach (dynamic item in ViewBag.EstadosDeAlma){ #(item + " ") }';
In addition, if I use any rich text editor as Tiny MCE all non-latin characters are like this too.
What should I do to avoid this problem?
What output encoding are you using on your web pages? I would suggest using UTF-8 since you want a lot of non-ascii characters to work.
I think you should HTML encode/decode the values before comparing them.
Since you are using jQuery you can take advantage of the encoding functions built-in into it. For example:
$('<div/>').html('& #225;gil').html()
gives you "ágil" (notice that I added an extra space between the & and the # so that stackoverflow does not encode it, you won't need it)
This other question has more information about this.
HTML-encoding lost when attribute read from input field