I am trying to paste Hindi characters in an array with elements like
String[] arr = {"आपका स्वागत है","आपका स्वागत है"};
but its giving error i.e.
"some characters cannot be mapped using "Cp1252" character encoding"
while saving this.
Switch your text encoding to UTF-8.
In Eclipse go to Window -> Preferences, select General -> Workspace. From the Text file encoding dropdown, select UTF-8.
Thanks i found the solution...
create an array under the value folder
Use the font that support Hindi under the assets folder
textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/Hindi.ttf")); its working fine...
You need UTF-8 encoding, not Cp1252, and Unicode.
Thanks i found the solution...
Create an array under the value folder
Use the font that support Hindi under the assets folder
textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/Hindi.ttf"));
its working fine...
Related
I have got the problem, that I can't display special characters like 'ß, ö, ä, ü' in my app.
The result is like this:
Or like this:
In Android Studio I get no error or warning and I am using the windows-1251 encoding.
In gradle I added this line: compileOptions.encoding = 'windows-1251'
It shall be german encoding.
How to fix that?
I actually can change special characters like 'ß' from predefined Strings with Html.fromHtml( unicode of the special character) like Html.fromHtml ( "ß" )
But what if a non predefined String contains a special Character? I have tried to simple replace the special character like this:
String neuer_String = get_street_adress.replace ( "ß", Html.fromHtml ( "ß" ) ) ;
straße.setText ( "Stra" + Html.fromHtml ( "ß" ) + "e: " + neuer_String);
But this doesn't work, because the string FriedhofstraÃe for example should be Friedhofstraße. So there is no character 'ß' in the string.
I also tried to change the font with Typeface but a exception is thrown: "native typeface cannot be made"
It's probably 'cause of the font in your device.
The way you can resolve this is by coding a Typeface out of a working font that you have tested.(e.g in Word,etc)
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/theNameOfTheFont.ttf");
Remember to place the code in fonts folder in assets. If you don't have one, create it.
Using UTF-8 encoding "might" solve your problem.
It's strongly recommended to use UTF-8 encoding.
With UTF-8 encoding, you can easily use the unicode value in your string.xml.
Here the a Link to XML character Entities List.
For example for ß use <string name="text szlig">text ß</string>
Go to the settings of Android Studio. In the File Encoding tab, make everything be formatted as UTF-8.
If the problem still persists, then the problem is in the font you are using as it may not support special characters.
I have found a solution for your problem, check it:
You can save all your strings with special characters in your strings.xml like:
<resources>
<string name="street">Straße</string>
</resources>
Then retrieve them in code like:
String street = getResources().getString(R.string.street);
You can definitely try other german characters out. Hope that works for you!
An error message is appeared when i was trying to create an app in malayalam.What can i do to solve this.
Error:Some characters cannot mappped using "Cp 1252"character encoding.
Switch your text encoding to UTF-8.
In Eclipse go to Window -> Preferences, select General -> Workspace. From the Text file encoding dropdown, select UTF-8.
do as follows:
download AnjaliOldLipi.ttf font.that's the malayalam font .search google for the file.
under your android assets folder create if not exist the folder fonts: assets/fonts/AnjaliOldLipi.ttf
then display texts this way were textview is a TextView: textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/AnjaliOldLipi.ttf"))
I'm trying to generate PDF file that contains Hebrew words.
When file is created all the Hebrew letters are deleted and only the English one are
in the file.
Can any one help me with this problem?
I'm using iText 5.4.3
This is my code when i add a new paragraph
Paragraph p0 = new Paragraph("טופס קריאת שירות");
BaseFont unicode = BaseFont.createFont("assets/fonts/arial.ttf", BaseFont.IDENTITY_H , BaseFont.EMBEDDED);
Font fontHebrew = new Font(unicode, 12, Font.NORMAL);
p0.setAlignment(Paragraph.ALIGN_CENTER);
p0.setFont(fontHebrew);
//add paragraph to document
doc.add(p0);
Thank's.
The code you added is wrong on many levels.
You're adding Hebrew characters in source code. These characters can get lost if the file is saved using the wrong encoding, if the file is compiled using the wrong encoding, etc... Use the Unicode notation instead of actual characters.
Maybe not wrong, but to be checked: you're using arial.ttf, shouldn't you be using arialuni.ttf? Also: make sure you pack the ttf in your APK (you wouldn't be the first to forget to ship a resource).
I can't read Hebrew, but I know it's written from right to left. RTL isn't supported in the Paragraph class, only in PdfPCell and ColumnText.
See the examples to find out how it's done: say_peace.pdf is done using a table; ligatures_2.pdf is done using a column (the second example is in Arabic, but it's the same principle as Hebrew).
I have a Swedish word Pågår in my string XML file. When I try to read this word form the string resources it only shows P g r with å character missing in the output. Why is this happening and how can I solve this? Please help me in solving this error.
You can (should) escape special letters with the utf-8 representation for it.
Both \u00e5 and å would work for "å" in Android.
As requested, an example of localized fonts according to link.
To use localized Fonts, you can put the special fonts in assets and name it something like "se-font.ttf"
In your strings.xml for the Swedish language you add a value:
<string name="fontprefix">se-</string>
Then, in your app, when you load the font, you create the asset filename like so:
String fontasset = getString(R.string.fontprefix, "") + "font.ttf";
Then you should be able to load your font using the fontasset filename
in eclipse try to change the xml encoding: - Window->Preferences->XML->XML Files->Encoding
EDIT: And make sure that the font you are using support this character. (just remembered this one - Translate my app to Hungarian )
For Android Platform:
I need to put Hebrew Character ₪ and some more like אורנג in string to check with the incoming data in java file. When I put this character It shows an error like "Some characters can not be mapped using "Cp1252" character encoding. Either change the encoding or remove the characters which are not supported by the "Cp1252" character encoding". These values are coming from SQLite database. Please see the attached snap. How can I solve this? Kindly give me some useful suggestions. Looking forward to hear from anybody who has a suggestion for me. Thanks.
Please open your eclipse.ini file from your eclipse folder with Note Pad and put the following permission into that.
-Dfile.encoding = UTF-8
Some more options as well:
For setting the encoding on a per WorkSpace basis, use Preferences->General->Workspace
To set the encoding on a per project basis open project properties and change to UTF-8
Hope this one help.
I think you'll need UTF-8 encoding for that.
These things are a little bit confusing. Reading this might clear some of the mist around encodings and character sets.
I think this may useful to you.
Keep this hebrew word in string.xml file. You can retrieve as
in String.xml
place hebrew word here
In java code:
String s=getString(R.string.hebrew_word);
Use this string as you want..