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
Help evaluating integral (anything simple that I am missing?)
Is it okay for a ticket seller to grab a tip in the USA?
Why are Gatwick's runways too close together?
What are the conventions for transcribing Semitic languages into Greek?
Ex-contractor published company source code and secrets online
Three legged NOT gate? What is this symbol?
Is it incorrect to write "I rate this book a 3 out of 4 stars?"
Can you castle with a "ghost" rook?
Does this Foo machine halt?
Trying to write a shell script that keeps testing a server remotely, but it keeps falling in else statement when I logout
What does Apple mean by "This may decrease battery life"?
Wherein the Shatapatha Brahmana it was mentioned about 8.64 lakh alphabets in Vedas?
How can I iterate this process?
Is Calculus necessary for computer science student?
In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?
Simple Stop watch which i want to extend
First amendment and employment: Can a police department terminate an officer for speech?
I accidentally overwrote a Linux binary file
How to create all combinations from a nested list while preserving the structure using R?
Dropdowns & Chevrons for Right to Left languages
Blocking people from taking pictures of me with smartphone
What skills in 5e give trap knowledge (i.e. the equivalent of Dungeoneering in 4e)?
Plausibility of Ice Eaters in the Arctic
Was the 2019 Lion King film made through motion capture?
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;
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
add a comment |
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
check out?Quotes
, it seems like R interprets"xnn"
as character with the hexcodenn
. I do not know if there is a workaround for this behaviour
– brettljausn
Mar 27 at 8:48
add a comment |
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
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
r regex encoding special-characters
edited Mar 27 at 9:18
TobiSonne
asked Mar 27 at 8:26
TobiSonneTobiSonne
1079 bronze badges
1079 bronze badges
check out?Quotes
, it seems like R interprets"xnn"
as character with the hexcodenn
. I do not know if there is a workaround for this behaviour
– brettljausn
Mar 27 at 8:48
add a comment |
check out?Quotes
, it seems like R interprets"xnn"
as character with the hexcodenn
. 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
add a comment |
1 Answer
1
active
oldest
votes
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
x <- readLines("test.txt")
. Nowx
is still"M\xfcller"
. I want to passx
to another function andx
has to be"Mxfcller"
– TobiSonne
Mar 27 at 9:15
R treat strings a little bit differently. If you tryx = "Mxfcller"
, you get "Müller".
– dipetkov
Mar 27 at 9:26
Also, you can see in the file that the string isMxfcller
but R shows it asM\xfcller
.
– dipetkov
Mar 27 at 9:31
s <- "ab"
andprint(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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
x <- readLines("test.txt")
. Nowx
is still"M\xfcller"
. I want to passx
to another function andx
has to be"Mxfcller"
– TobiSonne
Mar 27 at 9:15
R treat strings a little bit differently. If you tryx = "Mxfcller"
, you get "Müller".
– dipetkov
Mar 27 at 9:26
Also, you can see in the file that the string isMxfcller
but R shows it asM\xfcller
.
– dipetkov
Mar 27 at 9:31
s <- "ab"
andprint(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
add a comment |
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
x <- readLines("test.txt")
. Nowx
is still"M\xfcller"
. I want to passx
to another function andx
has to be"Mxfcller"
– TobiSonne
Mar 27 at 9:15
R treat strings a little bit differently. If you tryx = "Mxfcller"
, you get "Müller".
– dipetkov
Mar 27 at 9:26
Also, you can see in the file that the string isMxfcller
but R shows it asM\xfcller
.
– dipetkov
Mar 27 at 9:31
s <- "ab"
andprint(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
add a comment |
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
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
answered Mar 27 at 9:11
dipetkovdipetkov
1,4961 silver badge8 bronze badges
1,4961 silver badge8 bronze badges
x <- readLines("test.txt")
. Nowx
is still"M\xfcller"
. I want to passx
to another function andx
has to be"Mxfcller"
– TobiSonne
Mar 27 at 9:15
R treat strings a little bit differently. If you tryx = "Mxfcller"
, you get "Müller".
– dipetkov
Mar 27 at 9:26
Also, you can see in the file that the string isMxfcller
but R shows it asM\xfcller
.
– dipetkov
Mar 27 at 9:31
s <- "ab"
andprint(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
add a comment |
x <- readLines("test.txt")
. Nowx
is still"M\xfcller"
. I want to passx
to another function andx
has to be"Mxfcller"
– TobiSonne
Mar 27 at 9:15
R treat strings a little bit differently. If you tryx = "Mxfcller"
, you get "Müller".
– dipetkov
Mar 27 at 9:26
Also, you can see in the file that the string isMxfcller
but R shows it asM\xfcller
.
– dipetkov
Mar 27 at 9:31
s <- "ab"
andprint(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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
check out
?Quotes
, it seems like R interprets"xnn"
as character with the hexcodenn
. I do not know if there is a workaround for this behaviour– brettljausn
Mar 27 at 8:48