Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed yesterday.
Improve this question
The source files of the *.texi Guile manual have been translated into Russian. When assembling the manual using texi2any, an error occurs:
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1338.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1339.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1340.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1341.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 1992.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4111.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4112.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4113.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4114.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4115.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4116.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1338.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1339.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1340.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1341.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 1992.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4111.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4112.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4113.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4114.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4115.
Malformed UTF-8 character (unexpected end of string) in substitution (s///) at /usr/share/texinfo/Texinfo/Convert/HTML.pm line 4116.
Malformed UTF-8 character: \xd0 (too short; 1 byte available, need 2) in pattern match (m//) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1483.
Malformed UTF-8 character (fatal) at /usr/share/texinfo/Texinfo/Convert/Converter.pm line 1483.
The output assumes that the wrong character is processed twice Help to find this unrecognized character in the source *.texi files.
Related
I'm writing strings which contain backslashes (\) to a file:
x1 = "\\str"
x2 = "\\\str"
# Error: '\s' is an unrecognized escape in character string starting "\\\s"
x2="\\\\str"
write(file = 'test', c(x1, x2))
When I open the file named test, I see this:
\str
\\str
If I want to get a string containing 5 backslashes, should I write 10 backslashes, like this?
x = "\\\\\\\\\\str"
[...] If I want to get a string containing 5 \ ,should i write 10 \ [...]
Yes, you should. To write a single \ in a string, you write it as "\\".
This is because the \ is a special character, reserved to escape the character that follows it. (Perhaps you recognize \n as newline.) It's also useful if you want to write a string containing a single ". You write it as "\"".
The reason why \\\str is invalid, is because it's interpreted as \\ (which corresponds to a single \) followed by \s, which is not valid, since "escaped s" has no meaning.
Have a read of this section about character vectors.
In essence, it says that when you enter character string literals you enclose them in a pair of quotes (" or '). Inside those quotes, you can create special characters using \ as an escape character.
For example, \n denotes new line or \" can be used to enter a " without R thinking it's the end of the string. Since \ is an escape character, you need a way to enter an actual . This is done by using \\. Escaping the escape!
Note that the doubling of backslashes is because you are entering the string at the command line and the string is first parsed by the R parser. You can enter strings in different ways, some of which don't need the doubling. For example:
> tmp <- scan(what='')
1: \\\\\str
2:
Read 1 item
> print(tmp)
[1] "\\\\\\\\\\str"
> cat(tmp, '\n')
\\\\\str
>
I'm writing strings which contain backslashes (\) to a file:
x1 = "\\str"
x2 = "\\\str"
# Error: '\s' is an unrecognized escape in character string starting "\\\s"
x2="\\\\str"
write(file = 'test', c(x1, x2))
When I open the file named test, I see this:
\str
\\str
If I want to get a string containing 5 backslashes, should I write 10 backslashes, like this?
x = "\\\\\\\\\\str"
[...] If I want to get a string containing 5 \ ,should i write 10 \ [...]
Yes, you should. To write a single \ in a string, you write it as "\\".
This is because the \ is a special character, reserved to escape the character that follows it. (Perhaps you recognize \n as newline.) It's also useful if you want to write a string containing a single ". You write it as "\"".
The reason why \\\str is invalid, is because it's interpreted as \\ (which corresponds to a single \) followed by \s, which is not valid, since "escaped s" has no meaning.
Have a read of this section about character vectors.
In essence, it says that when you enter character string literals you enclose them in a pair of quotes (" or '). Inside those quotes, you can create special characters using \ as an escape character.
For example, \n denotes new line or \" can be used to enter a " without R thinking it's the end of the string. Since \ is an escape character, you need a way to enter an actual . This is done by using \\. Escaping the escape!
Note that the doubling of backslashes is because you are entering the string at the command line and the string is first parsed by the R parser. You can enter strings in different ways, some of which don't need the doubling. For example:
> tmp <- scan(what='')
1: \\\\\str
2:
Read 1 item
> print(tmp)
[1] "\\\\\\\\\\str"
> cat(tmp, '\n')
\\\\\str
>
I have the following variables in Unix Korn Shell
host=nyc43ksj
qry_dir='\test\mydoc\mds'
fullpath="\\$host\$qry_dir"
echo "$fullpath"
When I execute the above, I get output such as \nyc43ksj\qrydir.
It looks like the backslashes are used as escape characters.
I tried changing fullpath as follows:
fullpath="\\$host\\$qry_dir"
echo "$fullpath"
This time I get \nyc43ksj\test\mydoc\mds. However, the two backslashes at the beginning are not display as two backslashes. How can get the fullpath as \\nyc43ksj\test\mydoc\mds (two backslashes at the beginning).
In a string, the \ (backslash) character acts as an escape character (as you mention), and the second backslash instructs the shell to put in an actual backslash, as opposed to some special character.
If you want to have two actual backslash characters in the string in sequence, you will need to put \\\\ in the string, so:
fullpath="\\\\$host\\$qry_dir"
I want to sprintf a string with a "\" in it but it doesn't work:
sprintf("& $\pm %s \delta$", 1.23)
Error: '\p' is an unrecognized escape in character string starting ""& $\p"
I have tried:
sprintf("& $\\pm %s \\delta$", 1.23)
[1] "& $\\pm 1.23 \\delta$"
But I need the result with "& $\pm 1.23 \delta"
How can I get the right result?
Not sure what you're using it for but the \\ will work if you're trying to use it in a .Rnw file for instance but R needs the \\. If you just want to cut and paste it somewhere wrap it with cat as in: cat(sprintf("& $\\pm %s \\delta$", 1.23))
The \ has an especial use. For example, \n is the new line character and will be printed as such and not as "\n".
If you want to print backslash, escape it with another backslash. So "\" will print a single backslash.
Hope I helped.
just write \\ - that will produce you a single slash. This is because a slash is a special character and it needs to be escaped before be printed ;)
I'm writing strings which contain backslashes (\) to a file:
x1 = "\\str"
x2 = "\\\str"
# Error: '\s' is an unrecognized escape in character string starting "\\\s"
x2="\\\\str"
write(file = 'test', c(x1, x2))
When I open the file named test, I see this:
\str
\\str
If I want to get a string containing 5 backslashes, should I write 10 backslashes, like this?
x = "\\\\\\\\\\str"
[...] If I want to get a string containing 5 \ ,should i write 10 \ [...]
Yes, you should. To write a single \ in a string, you write it as "\\".
This is because the \ is a special character, reserved to escape the character that follows it. (Perhaps you recognize \n as newline.) It's also useful if you want to write a string containing a single ". You write it as "\"".
The reason why \\\str is invalid, is because it's interpreted as \\ (which corresponds to a single \) followed by \s, which is not valid, since "escaped s" has no meaning.
Have a read of this section about character vectors.
In essence, it says that when you enter character string literals you enclose them in a pair of quotes (" or '). Inside those quotes, you can create special characters using \ as an escape character.
For example, \n denotes new line or \" can be used to enter a " without R thinking it's the end of the string. Since \ is an escape character, you need a way to enter an actual . This is done by using \\. Escaping the escape!
Note that the doubling of backslashes is because you are entering the string at the command line and the string is first parsed by the R parser. You can enter strings in different ways, some of which don't need the doubling. For example:
> tmp <- scan(what='')
1: \\\\\str
2:
Read 1 item
> print(tmp)
[1] "\\\\\\\\\\str"
> cat(tmp, '\n')
\\\\\str
>