Yii2 widget fileinput utf-8 charset problem - file-upload

I would like to upload a filename with utf-8 characters such as greek, german etc. The upload occurs successfully for both file size and type, unfortunately its filename is being replaced by strange characters. However when english characters for filename are used, there is no problem at all.
Any idea what it might be wrong with utf-8 characters regarding filename for this specific Yii2 widget plugin?
I provide you with the filename being generated for utf-8 characters
and additionally the function source code that produces filename via _slugDefault (added extra line for no special characters).
Regards

I found that it actually depends on the server OS file system language settings and not by the widget itself. So i used the following php function in my controller:
$file_name=iconv('UTF-8', 'language//TRANSLIT',$model->field);
$file->saveAs('files/'.$file_name);
Thanks a lot and i am indeed very happy to solve it on myself!

Related

UTF-8 without BOM in php files

on every page on my site see these symbols "  "
idon't know why some people suggested to put charset=\"UTF-8\" at the top of the page
but also didn't work
can someone help me?
Try loading your code files in Notepad++ and then selecting Encoding > Encode in UTF-8 without BOM.

Convert unicode chars in xml to ascii

InDesign can export an XML file, and it will also "Remap break, whitespace, and special characters" if you check the box to do that. How can I do the same thing on text?
For example, if I have: •this is a bullet —long dash
InDesign exports as: &# 8226;this is a bullet &# 8212;long dash
I don't know what kind of encoding this is. Can a standard Objective-C class do this (working on OS X) or a third party library?
They are an HTML thing. People usually refer to as HTML encoding but technically, they are Numeric character references. There is nothing built into Foundation that decodes them, but if you look around you can find some code to handle it (for example, https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString+HTML.m).

NSString&NSURL and Russian language

In my app I have an NSURL which is a file path. If a file or a folder's name contains Russian characters, instead of normal path, something like "/Users/user/Downloads/%D0%94%D0%BE%D0%BC%D0%B0%D1%88%D0%BD%D0%B5%D0%B5 %D0%B7%D0%B0%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5 %D0%BD%D0%B0 %D0%BB%D0%B5%D1%82%D0%BE.doc" is displayed.
Is there a way to fix it?
Thanks in advance!
This is expected behaviour for NSURL, since file urls cannot contain special characters.
What are you trying to do with the URL? If you're using it do get a file from the system it should work. It seems like you're trying to display the path to the user, where and in what context?

Special characters in iText

I need help in using these symbols ⎕, ∨, ๐, Ʌ, and so on. But when I create a PDF with iText these symbols do not appear.
What can I do so that these symbols appear?
You have to use a font and encoding that contains those characters. Your best bet is to use IDENTITY_H for your encoding, as this grants you access to every character within a given font... but you still have to use the right font.
There are several font-manipulation examples within "iText in Action's" chapter on fonts:
http://www.itextpdf.com/book/chapter.php?id=11
The examples are down the right side. Buying the book would probably help too.
I had the same problem too and I figured out using IDENTITY_H for encoding is working fine.
For example:
java.awt.Font f =...;
Font font = FontFactory.getFont(f.getName(),BaseFont.IDENTITY_H)
I don't understand why with BaseFont.WINANSI it doesn't work. Winansi is the standard Windows Cp1252 character set, that one used by my JVM. So, if the char is correctly displayed in Java, why it is not the case for PDF?
You can escape them according to the unicode escape sequence defined in the java language specification. See http://java.sun.com/docs/books/jls/first_edition/html/3.doc.html
If you are using IntelliJ IDEA for your code you can download the StringManipulation plugin, that does the escapes for you. In the settings of IDEA you can also set the "Transparent native-to-ascii conversion" checkbox under File encodings, and this should help do the trick.
square in pdf file by iText:
BaseFont bf = BaseFont.createFont("c:/windows/fonts/arialbd.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
question.add(new Phrase("\u25A1", new Font(bf, 26)));
You can see a pdf file exemple here

zend_pdf can't read existing pdf

I'm using Zend_Pdf to generate PDF files, based on existing PDF templates. The problem is, I can't read any of the templates - I get a "File is not a PDF." error because the first 4 characters in the file are "%???" instead of "%PDF" (I used "head" to check this).
Is this a character encoding problem? I believe the templates are in ISO-8859-1, must I set something in Zend_Pdf_Parser to handle this?
Thanks
to answer my own question, I moved to Perl PDF::Extract and it's working.