Silverlight displaying asia language? - c#

My application require 2 different asia language support: Chinese and Tamil.
It should be able to cater for change without compiling, something like java's resource bundle.
In this case, if I input unicode on a external file and get silverlight to read as string, will silverlight be able to parse it correctly?
Or I can use the chinese/ tamil characters directly in the external file, but I'm not sure how to retrieve these characters in code.
Anyway these language will be shown on the same screen, so I don't think localization will help.

Just place the content in Xml (probably Xaml Resource dictionary) using the default UTF-8 encoding.

Related

Write PDF other than English language C#.Net or Angular

I have been trying to read a pdf file and convert it into another language selected by user via Google API. then I need to save the translated content to another file.
I have generated pdf file using c#.net and Angular but both are only supporting English language while most probably I have to translate file from English to other languages.
I have used jsPDF for angular and for C#.Net I have used UglyToad.PdfPig but I am not able to save other languages
did you try other PDF generation libraries?
i use PDFFlow and I know it supports latin, cyrillic and asian languages
For example this simple code creates Chinese text :
{
DocumentBuilder.New()
.AddSection()
.AddParagraph("在这输 在入文这输 入文字")
.SetFontEncodingName(EncodingNamesChineseSimplified.GBK_EUC_H)
.SetFontName(FontNamesChineseSimplified.SimSun).ToDocument()
.Build("Result.pdf");
}
the result pdf will be this:
try and tell me if you need further help or have any questions

Winforms Webbrowser Control and Character Encoding

I am trying to use the Winforms WebBrowser control to display a webpage that can be in many different languages. In one example, I have a HTML file that has characters in Farsi (examples are not limited to this, however - the file can have Mongolian, Japanese, or any other language).
When I try to Navigate() to this file in the WebBrowser control, it displays in a bunch of garbled characters (eg. ÓÇÚÊ). If I display the same file in Firefox, however, it will correctly display with all the the expected characters (eg. ساعت). I can also load the raw HTML file in Notepad++ and it seems to automatically detect the character set/encoding that is being used.
I have read numerous threads that talk about setting the WebBrowser encoding like so:
webBrowser.Document.Encoding = "UTF-8"
however given a set of HTML files, I have no way of telling what language it is written in and therefore no way to know the encoding. I can also confirm there is no "meta" tag within the HTML source that specifies any encoding.
Is there some magic going on behind the scenes of Firefox and Notepad++ to detect the correct character set and if so, how? Can someone tell me how I can get the WebBrowser control to behave in a similar way?
As #Bizan pointed out, in the absence of meta tags to describe the encoding, modern browsers seem to use heuristics to determine the language encoding.
Since the WebBrowser control is based on dated Internet Explorer technology, it appears there is no in-built logic to do these heuristics automatically.
The solutions are:
Implement your own heuristics method and then set the encoding manually.
Use the WebView control (as mentioned by #PanagiotisKanavos) which appears to be use the latest Edge browser. I have tested the pages in Edge and they work correctly. The minimum requirement for WebView is Windows 10 however, which will rule out any use-cases where you need your software to run on earlier versions of Windows.

Localize FlipView binded to data in C#

I'm developing an UWP app in C#. It needs to support both English and French and the first screen contains a FlipView bound to JSON data.
How could I localize the text content inside this FlipView?
I have thought of multiple ways:
In the JSON, add translated fields for each view. This means I'll need to retrieve the current language and change the way I parse the JSON according to it.
Do another JSON and choose which one to parse according to the language I retrieve.
What would you do and what is the most efficient? Is there another way? As I'm already using XAML resource files to translate other UI strings. If there is not, is there a way to retrieve language information in C#?
Thanks.
well there is not easy way to solve your problem.
You will need translate the words of your json manually but I recommend you to use Bing Translator Api is very easy to use.
you can send your word to be translated to another language ans show the result in your UI
https://www.microsoft.com/en-us/translator/getstarted.aspx
Finally I just made it so that there is a JSON file for each language. I then switch the file according to the system language at load time.

ANSI vs SHIFT JIS vs UTF-8 in c#

I have been trying to figure the difference for quite sometime now. The issue is with a file that is in ANSI encoding has japanese characters like: ­‚È‚­‚Æ‚à1‚‚ÌINCREMENTs‚ª•K—v‚Å‚·. It equivalent in shift-jis is 少なくとも1つのINCREMENT行が必要です. which is expected to be in japanese.
I need to display these characters after reading from file(in ANSI) on a webpage. There are some other files in UTF-8 displaying characters right not seeing this. I am finding it difficult to figure out whats the difference and how do I change encoding to do right things here..
I use c# for reading this file and displaying it, I also need to write the string back into file if its modified on web. Any encoding and decoding schemas here?
As far as code pages are concerned, "ANSI" (and Encoding.Default in .NET) basically just means "the non-Unicode codepage used by this system" - exactly what codepage that is, depends on how the system is configured, but on a Western European system, it's likely to be Windows-1252.
For the system where that text comes from, then "ANSI" would appear to mean Shift-JIS - so unless your system has the same code page, you'll need to tell your code to read the text as Shift-JIS.
Assuming you're reading the file with a StreamReader, there are various constructors that take an Encoding, so just grab a Shift-JIS encoding with Encoding.GetEncoding("shift_jis") or Encoding.GetEncoding(932) and use it to construct your StreamReader.

Japanese culture in C# application in English OS

I have an application in C# using .net 3.5. Using this application I save an file and zip it using vjlib library and while opening the file I unzip it. However when I try to give file name as Japanese when saving it in English OS machine the file while opening it the application it not able to understand Japanese character. It due to some Windows Language pack etc.
This problem is most likely induced by the application that created the .zip file. File names are encoded in 8 bit characters inside the file. The ZIP specification says that the name should be encoded either in code page 437 or in utf-8. Code page 437 is the original IBM PC character set, an encoding that doesn't support any Japanese characters. It is not unusual for an app to just use its own 8-bit encoding, not untypically determined by the default system code page.
The library you use is the .NET runtime support library for JScript. Not sure it support specifying a different encoding, it is hard to find docs for it these days since it has been deprecated for so long. Consider, say, dotnetzip. Its ZipFile class has an AlternateEncoding property you can initialize from Encoding.GetEncoding(). You still need to find out what encoding was used, knowing where the file came from is important help to make the right guess. One common code page for Japanese is 932.

Categories