# Tag Info

## Hot answers tagged unicode

22

Since a native method is not forthcoming, I shall post my file based circumvention, for Windows. You will need to have this utility in the command path (it apparently is stock with Windows 7). copyUnicode[expr_] := Run["clip <", Export["$Clipboard.temp", ToString[expr, InputForm], "Text", CharacterEncoding -> "Unicode"] ]; Usage: expr ... 16 Declaration: This method for Windows is based on the .NET code from Todd Gayley's this wonderful answer. My .NET knowledge is absolutely ZERO, all credit goes to Todd. Code: The main idea is to extract the "Input"-style code string, convert it to the UTF-16 little endian form, which is the standard byte order in Windows, feed the bytes to system clipboard ... 15 See if this helps: Needs["JLink"]; ClearAll[toUpperCase]; toUpperCase[s_String] := JavaBlock[JavaNew["java.lang.String", s]@toUpperCase[]]; 11 Edit 2: A new version of the Mac solution with button is listed below Fixed problem with pasting into textarea In some applications on Mac, copying as Unicode from Mathematica already works without having to do any postprocessing. However, it doesn't work in textarea fields in web browsers. Nevertheless, if you're willing to do a few additional mouse ... 7 Reposting John Fultz’s comment above as a “community wiki” answer for everyone to improve: Mathematica simply has no support for non-plane-0 characters. That it appears to temporarily work should not fool you into thinking that M-- knows anything about such values. Those who saw the R&D keynote at the 2011 Tech Conference may remember my ... 7 I use a small web application for when there are too many to convert by hand. 7 Here's a version that doesn't require a temporary file. Linux (needs xclip) SetAttributes[copyUnicode, HoldAll]; copyUnicode[expr_] := With[{ stream = OpenWrite["!xclip -in -selection clipboard", CharacterEncoding -> "UTF-8"] }, WriteString[stream, ToString[Unevaluated@expr, InputForm]]; Close@stream; ]; Example: executing the cell ... 6 It seems that the problem can be solved by setting explicit value of the CharacterEncoding global FE option (checked with MMa 8.0.4 and 9.0.0): SetOptions[$FrontEnd, CharacterEncoding -> "UTF8"]; Export["test.pdf", "кириллический текст"] An equivalent way (without changing the global FE settings): Export["test.pdf", Style["кириллический текст", ...

6

I had started working on a homegrown solution to this issue, directly by downloading Unicode data from the source. I’ll post it here, as it may be expanded to other functions were Java might not come and save the day! unicodeData = StringSplit[#, ";"] & /@ StringSplit[Import["ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt"], "\n"]; ...

6

Here is a function that copies a Unicode string to the clipboard using JLink: Needs["JLink"]; InstallJava[]; LoadJavaClass["java.awt.Toolkit", AllowShortContext -> False]; uniclip[s_String] := JavaBlock[ javaawtToolkitgetDefaultToolkit[]@getSystemClipboard[]@setContents[#, #]& @ JavaNew["java.awt.datatransfer.StringSelection", s] ...

5

The correct character encoding for Export may help. Export["hello.txt", str, "Text", CharacterEncoding -> "Unicode"] does the trick for me:

4

Here's how to add a permanent menu item and keyboard shortcut for Silvia's solution. (This can be easily adapted to Jens' solution for Mac OS.) 1. Add Package Copy Silvia's first code block that starts with Needs["NETLink"] to a file and save it as UniCodeCopy.m in one of the directories included in $Path. 2. Initialize the Front End Save the ... 4 The following workaround works at least for Linux with Mathematica version 8.0.0.0; it might work on other systems, too: Step 1: Open a terminal window (with UTF8 encoding) and start directly the kernel there. Step 2: Enter$CharacterEncoding="UTF8" and press Enter. Ideally the kernel would figure that out itself from the locale, but for some reason it ...

3

I found the following workaround for Windows systems. Go to the Control Panel and select Regional & Language Options. Under the Advanced tab select "Greek" as the language for non-Unicode programs. Note that the option to change is not the language for "Standards and Formats". It is the language for non-Unicode programs. Now Greek letters will be ...

2

Hbar asked: What is the logic of the junk ExportString prints into a cell? On my system (Mathematica 7, Windows 7) I don't get quite the same result, but I assume the mechanism is similar. If we use ToCharacterCode to convert our intended string into UTF-8 we get multi-byte encoding: utf8 = ToCharacterCode["Hello \[RightArrow] World!", "UTF8"] ...

1

It's on my list of things to tackle as part of the Incremental Language Development project. In the meantime, there is a built-in solution that is fairly fast, which is: Needs["MachineLearning`"]; ToUpperCaseUnicode[{"éàÇœßþ\[Sigma]\[FinalSigma]", "ĳķǌđӽծ", "ÿ"}] {"ÉÀÇŒSSÞ[CapitalSigma][CapitalSigma]", "ĲĶǊĐӼԾ", "Ÿ"} (not sure how to copy-paste the ...

1

If the goal is to write latex, why not use "Tex" export which gives nice looking Latex hw = {72, 101, 108, 108, 111, 32, 8594, 32, 87, 111, 114, 108, 100, 33}; str = FromCharacterCode[hw]; ExportString[str, "Tex"] or more simply TeXForm[str] \text{Hello $\rightarrow$ World!}

Only top voted, non community-wiki answers of a minimum length are eligible