How to get the raw numeric HTML representation of special characters?What special characters must be escaped in regular expressions?Detect encoding and make everything UTF-8Form character encoding problems with special charactersUTF-8 in Windows 7 CMDHow to correctly insert utf-8 characters into a MySQL table using jpaHow change the default UTF-8 encoding to LATIN1All special characters are question marks in PHP/HTMLusing special characters in jquery html not showing correctlyChanging default encoding of vim to utf-8 not workingReplace special characters in a string (like "{ by { ) in R

How far did Gandalf and the Balrog drop from the bridge in Moria?

Understanding the point of a kölsche Witz

Bitcoin successfully deducted on sender wallet but did not reach receiver wallet

How to create events observer that only call when REST api dispatch events?

Safest way to store environment variable value in a file

How can God warn people of the upcoming rapture without disrupting society?

These were just lying around

Do beef farmed pastures net remove carbon emissions?

What is a good class if we remove subclasses?

Enigma between Collegues (Part1)

How many people would you need to pull a whale over cobblestone streets?

Boss wants me to ignore a software license

Heat equation: Squiggly lines

Is there a standardised way to check fake news?

How do some PhD students get 10+ papers? Is that what I need for landing good faculty position?

Can a PC use the Levitate spell to avoid movement speed reduction from exhaustion?

If clocks themselves are based on light signals, wouldn't we expect the measured speed of light to always be the same constant?

Are differences between uniformly distributed numbers uniformly distributed?

A continuous water "planet" ring around a star

Why did Gandalf use a sword against the Balrog?

Why is the result of ('b'+'a'+ + 'a' + 'a').toLowerCase() 'banana'?

On math looking obvious in retrospect

Why is there a large performance impact when looping over an array over 240 elements?

How can Radagast come across Gandalf and Thorin's company?



How to get the raw numeric HTML representation of special characters?


What special characters must be escaped in regular expressions?Detect encoding and make everything UTF-8Form character encoding problems with special charactersUTF-8 in Windows 7 CMDHow to correctly insert utf-8 characters into a MySQL table using jpaHow change the default UTF-8 encoding to LATIN1All special characters are question marks in PHP/HTMLusing special characters in jquery html not showing correctlyChanging default encoding of vim to utf-8 not workingReplace special characters in a string (like "{ by { ) in R






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















When I type "xfc" into R it leads to [1] "ü". I don't want that, I want this to lead to [1] "xfc". I also do not really understand why Encoding("xfc") is "latin1" although I changed the settings in Code->Saving to UTF-8. I want to write a function that replaces some special characters like "ü" by "xfc" but I can't achieve this:



> stringr::str_replace_all("Müller", "ü", "xfc")
[1] "Müller"
> stringr::str_replace_all("Müller", "ü", "\xfc")
[1] "Mxfcller"
> stringr::str_replace_all("Müller", "ü", "\xfc")
[1] "Müller"
> stringr::str_replace_all("Müller", "ü", "\\xfc")
[1] "M\xfcller"


What I really want is [1] "Mxfcller"



(How) can I achieve this?










share|improve this question


























  • check out ?Quotes, it seems like R interprets "xnn" as character with the hexcode nn. I do not know if there is a workaround for this behaviour

    – brettljausn
    Mar 27 at 8:48

















3















When I type "xfc" into R it leads to [1] "ü". I don't want that, I want this to lead to [1] "xfc". I also do not really understand why Encoding("xfc") is "latin1" although I changed the settings in Code->Saving to UTF-8. I want to write a function that replaces some special characters like "ü" by "xfc" but I can't achieve this:



> stringr::str_replace_all("Müller", "ü", "xfc")
[1] "Müller"
> stringr::str_replace_all("Müller", "ü", "\xfc")
[1] "Mxfcller"
> stringr::str_replace_all("Müller", "ü", "\xfc")
[1] "Müller"
> stringr::str_replace_all("Müller", "ü", "\\xfc")
[1] "M\xfcller"


What I really want is [1] "Mxfcller"



(How) can I achieve this?










share|improve this question


























  • check out ?Quotes, it seems like R interprets "xnn" as character with the hexcode nn. I do not know if there is a workaround for this behaviour

    – brettljausn
    Mar 27 at 8:48













3












3








3








When I type "xfc" into R it leads to [1] "ü". I don't want that, I want this to lead to [1] "xfc". I also do not really understand why Encoding("xfc") is "latin1" although I changed the settings in Code->Saving to UTF-8. I want to write a function that replaces some special characters like "ü" by "xfc" but I can't achieve this:



> stringr::str_replace_all("Müller", "ü", "xfc")
[1] "Müller"
> stringr::str_replace_all("Müller", "ü", "\xfc")
[1] "Mxfcller"
> stringr::str_replace_all("Müller", "ü", "\xfc")
[1] "Müller"
> stringr::str_replace_all("Müller", "ü", "\\xfc")
[1] "M\xfcller"


What I really want is [1] "Mxfcller"



(How) can I achieve this?










share|improve this question
















When I type "xfc" into R it leads to [1] "ü". I don't want that, I want this to lead to [1] "xfc". I also do not really understand why Encoding("xfc") is "latin1" although I changed the settings in Code->Saving to UTF-8. I want to write a function that replaces some special characters like "ü" by "xfc" but I can't achieve this:



> stringr::str_replace_all("Müller", "ü", "xfc")
[1] "Müller"
> stringr::str_replace_all("Müller", "ü", "\xfc")
[1] "Mxfcller"
> stringr::str_replace_all("Müller", "ü", "\xfc")
[1] "Müller"
> stringr::str_replace_all("Müller", "ü", "\\xfc")
[1] "M\xfcller"


What I really want is [1] "Mxfcller"



(How) can I achieve this?







r regex encoding special-characters






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 9:18







TobiSonne

















asked Mar 27 at 8:26









TobiSonneTobiSonne

10710 bronze badges




10710 bronze badges















  • check out ?Quotes, it seems like R interprets "xnn" as character with the hexcode nn. I do not know if there is a workaround for this behaviour

    – brettljausn
    Mar 27 at 8:48

















  • check out ?Quotes, it seems like R interprets "xnn" as character with the hexcode nn. I do not know if there is a workaround for this behaviour

    – brettljausn
    Mar 27 at 8:48
















check out ?Quotes, it seems like R interprets "xnn" as character with the hexcode nn. I do not know if there is a workaround for this behaviour

– brettljausn
Mar 27 at 8:48





check out ?Quotes, it seems like R interprets "xnn" as character with the hexcode nn. I do not know if there is a workaround for this behaviour

– brettljausn
Mar 27 at 8:48












1 Answer
1






active

oldest

votes


















0














The last line gives the result you want. The backslash is escaped when the string is printed. To see that, let's save the string to file and then see the content of the file.




s <- stringr::str_replace_all("Müller", "ü", "\\xfc")

writeLines(s, "test.txt")

cat(readLines("test.txt"))
#> Mxfcller


Created on 2019-03-27 by the reprex package (v0.2.1)



Also see this GitHub issue: https://github.com/STAT545-UBC/Discussion/issues/394






share|improve this answer

























  • x <- readLines("test.txt"). Now x is still "M\xfcller". I want to pass x to another function and x has to be "Mxfcller"

    – TobiSonne
    Mar 27 at 9:15












  • R treat strings a little bit differently. If you try x = "Mxfcller", you get "Müller".

    – dipetkov
    Mar 27 at 9:26











  • Also, you can see in the file that the string is Mxfcller but R shows it as M\xfcller.

    – dipetkov
    Mar 27 at 9:31











  • s <- "ab" and print(s) leads to "ab" und not "a\b" so there must be a difference? Or am I wrong?

    – TobiSonne
    Mar 27 at 11:30







  • 1





    R doesn't interpret "b" as a special character. Try "ax" and you get an error about "hex digits" which is what "xfc" is.

    – dipetkov
    Mar 27 at 11:52










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372670%2fhow-to-get-the-raw-numeric-html-representation-of-special-characters%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The last line gives the result you want. The backslash is escaped when the string is printed. To see that, let's save the string to file and then see the content of the file.




s <- stringr::str_replace_all("Müller", "ü", "\\xfc")

writeLines(s, "test.txt")

cat(readLines("test.txt"))
#> Mxfcller


Created on 2019-03-27 by the reprex package (v0.2.1)



Also see this GitHub issue: https://github.com/STAT545-UBC/Discussion/issues/394






share|improve this answer

























  • x <- readLines("test.txt"). Now x is still "M\xfcller". I want to pass x to another function and x has to be "Mxfcller"

    – TobiSonne
    Mar 27 at 9:15












  • R treat strings a little bit differently. If you try x = "Mxfcller", you get "Müller".

    – dipetkov
    Mar 27 at 9:26











  • Also, you can see in the file that the string is Mxfcller but R shows it as M\xfcller.

    – dipetkov
    Mar 27 at 9:31











  • s <- "ab" and print(s) leads to "ab" und not "a\b" so there must be a difference? Or am I wrong?

    – TobiSonne
    Mar 27 at 11:30







  • 1





    R doesn't interpret "b" as a special character. Try "ax" and you get an error about "hex digits" which is what "xfc" is.

    – dipetkov
    Mar 27 at 11:52















0














The last line gives the result you want. The backslash is escaped when the string is printed. To see that, let's save the string to file and then see the content of the file.




s <- stringr::str_replace_all("Müller", "ü", "\\xfc")

writeLines(s, "test.txt")

cat(readLines("test.txt"))
#> Mxfcller


Created on 2019-03-27 by the reprex package (v0.2.1)



Also see this GitHub issue: https://github.com/STAT545-UBC/Discussion/issues/394






share|improve this answer

























  • x <- readLines("test.txt"). Now x is still "M\xfcller". I want to pass x to another function and x has to be "Mxfcller"

    – TobiSonne
    Mar 27 at 9:15












  • R treat strings a little bit differently. If you try x = "Mxfcller", you get "Müller".

    – dipetkov
    Mar 27 at 9:26











  • Also, you can see in the file that the string is Mxfcller but R shows it as M\xfcller.

    – dipetkov
    Mar 27 at 9:31











  • s <- "ab" and print(s) leads to "ab" und not "a\b" so there must be a difference? Or am I wrong?

    – TobiSonne
    Mar 27 at 11:30







  • 1





    R doesn't interpret "b" as a special character. Try "ax" and you get an error about "hex digits" which is what "xfc" is.

    – dipetkov
    Mar 27 at 11:52













0












0








0







The last line gives the result you want. The backslash is escaped when the string is printed. To see that, let's save the string to file and then see the content of the file.




s <- stringr::str_replace_all("Müller", "ü", "\\xfc")

writeLines(s, "test.txt")

cat(readLines("test.txt"))
#> Mxfcller


Created on 2019-03-27 by the reprex package (v0.2.1)



Also see this GitHub issue: https://github.com/STAT545-UBC/Discussion/issues/394






share|improve this answer













The last line gives the result you want. The backslash is escaped when the string is printed. To see that, let's save the string to file and then see the content of the file.




s <- stringr::str_replace_all("Müller", "ü", "\\xfc")

writeLines(s, "test.txt")

cat(readLines("test.txt"))
#> Mxfcller


Created on 2019-03-27 by the reprex package (v0.2.1)



Also see this GitHub issue: https://github.com/STAT545-UBC/Discussion/issues/394







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 9:11









dipetkovdipetkov

1,4961 silver badge8 bronze badges




1,4961 silver badge8 bronze badges















  • x <- readLines("test.txt"). Now x is still "M\xfcller". I want to pass x to another function and x has to be "Mxfcller"

    – TobiSonne
    Mar 27 at 9:15












  • R treat strings a little bit differently. If you try x = "Mxfcller", you get "Müller".

    – dipetkov
    Mar 27 at 9:26











  • Also, you can see in the file that the string is Mxfcller but R shows it as M\xfcller.

    – dipetkov
    Mar 27 at 9:31











  • s <- "ab" and print(s) leads to "ab" und not "a\b" so there must be a difference? Or am I wrong?

    – TobiSonne
    Mar 27 at 11:30







  • 1





    R doesn't interpret "b" as a special character. Try "ax" and you get an error about "hex digits" which is what "xfc" is.

    – dipetkov
    Mar 27 at 11:52

















  • x <- readLines("test.txt"). Now x is still "M\xfcller". I want to pass x to another function and x has to be "Mxfcller"

    – TobiSonne
    Mar 27 at 9:15












  • R treat strings a little bit differently. If you try x = "Mxfcller", you get "Müller".

    – dipetkov
    Mar 27 at 9:26











  • Also, you can see in the file that the string is Mxfcller but R shows it as M\xfcller.

    – dipetkov
    Mar 27 at 9:31











  • s <- "ab" and print(s) leads to "ab" und not "a\b" so there must be a difference? Or am I wrong?

    – TobiSonne
    Mar 27 at 11:30







  • 1





    R doesn't interpret "b" as a special character. Try "ax" and you get an error about "hex digits" which is what "xfc" is.

    – dipetkov
    Mar 27 at 11:52
















x <- readLines("test.txt"). Now x is still "M\xfcller". I want to pass x to another function and x has to be "Mxfcller"

– TobiSonne
Mar 27 at 9:15






x <- readLines("test.txt"). Now x is still "M\xfcller". I want to pass x to another function and x has to be "Mxfcller"

– TobiSonne
Mar 27 at 9:15














R treat strings a little bit differently. If you try x = "Mxfcller", you get "Müller".

– dipetkov
Mar 27 at 9:26





R treat strings a little bit differently. If you try x = "Mxfcller", you get "Müller".

– dipetkov
Mar 27 at 9:26













Also, you can see in the file that the string is Mxfcller but R shows it as M\xfcller.

– dipetkov
Mar 27 at 9:31





Also, you can see in the file that the string is Mxfcller but R shows it as M\xfcller.

– dipetkov
Mar 27 at 9:31













s <- "ab" and print(s) leads to "ab" und not "a\b" so there must be a difference? Or am I wrong?

– TobiSonne
Mar 27 at 11:30






s <- "ab" and print(s) leads to "ab" und not "a\b" so there must be a difference? Or am I wrong?

– TobiSonne
Mar 27 at 11:30





1




1





R doesn't interpret "b" as a special character. Try "ax" and you get an error about "hex digits" which is what "xfc" is.

– dipetkov
Mar 27 at 11:52





R doesn't interpret "b" as a special character. Try "ax" and you get an error about "hex digits" which is what "xfc" is.

– dipetkov
Mar 27 at 11:52








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid …


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372670%2fhow-to-get-the-raw-numeric-html-representation-of-special-characters%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?