How can I output the title field with "%20" between each word? My mailto link is not validating because of the spaces, like:
mailto:?subject=My Title
I need:
mailto:?subject=My%20Title
Thanks a lot!
What you need to do is "URL encode" the title (that is, you need to convert any invalid chars to percent encoding, spaces aren't the only problem).
This plugin on Devot:ee sounds like it should do just the trick: URL Encode
Related
I am trying to print some text with emojis from this form text = "\\ud83d\\ude04\\n\\u3082\\u3042", into:
# my expecting output
# a new line after the emoji, then is Japanese character
>>>😄
もあ
I have read a question about this, but just solve part of the problem:
Best and clean way to Encode Emojis (Python) from text file
I followed the code mentioned in the post, and I got below result:
emoji_text = "\\ud83d\\ude04\\n\\u3082\\u3042".encode("latin_1")
output = (emoji_text
.decode("raw_unicode_escape")
.encode('utf-16', 'surrogatepass')
.decode('utf-16')
)
print(output)
>>>😄\nもあ
# it prints \n instead of a new line
Therefore, I would like to ask, how can I convert the escape sequences \n, \t, \b etc. while converting the emoji and text?
Using unicode_escape instead of raw_unicode_escape will decode the \n as well. Though if there is a reason you used raw_unicode_escape in the first place, perhaps this will not be suitable?
Your choice to encode into "latin-1" is vaguely odd, but perhaps there is a reason for that, too. Perhaps you should encode into "ascii" and be prepared to cope with any possible fallout.
I am having a hierarchy name like a.b.c.d.e in multiple lines along with some text. Now I want to change that as a/b/c/d/e.
I tried %s/\./\//g. It did not work.
Error:Trailing Characters
Plain and simple:
:%substitute~\.~/~g
So I recently used this following lua code to separate each word from string and notice it's not showing special characters (e.g. /,;,'). So is there anyway for it to show?
string = "Test, Im testing"
for word in string:gmatch("%w+") do
print(word)
end
This code will not show the commas on the string but I need it to show.
Instead of %w I think you are looking for %S pattern.
Alternatively you can also try [%w%p]+.
See a brief description of how lua pattern behave at lua pil
I would like to convert the special characters in "text" variable back normal in VBA!
Dim text As String
text = "Cs\u00fct\u00f6rt\u00f6k"
text = Encoding.utf8.GetString(Encoding.ASCII.GetBytes(text))
MsgBox text
'Csütörtök would be the correct result
But in the above code Excel 2013 gives me an error about "Encoding" method.. cant parse it.
It should be working just like this online converter if you put in the text value:
http://www.rapidmonkey.com/unicodeconverter/reverse.jsp
Is there any good solution for this problem? A one-line code maybe?
Thanks in advance!
The Encoding class does not decode escape sequences, you have to do that manually by parsing the string yourself. For that matter, VB strings use UTF-16, so you do not need to use the Encoding class at all. Simply replace characters 2-7 ("\u00fc") with a single &H00FC character, replace characters 9-14 ("\u00f6") with a single &H00F6 character, etc and then you are done. Each \uXXXX sequence represents a single Unicode codepoint.
Here's my problem:
I need to store sentences "somewhere" (it doesn't matter where).
The sentences must not contain spaces.
When I extract the sentences from that "somewhere", I need to restore the spaces.
So, before storing the sentence "I am happy" I could replace the spaces with a safe character, such as &. In C#:
theString.Replace(' ', '&');
This would yield 'I&am&happy'.
And when retrieving the sentence, I would to the reverse:
theString.Replace('&', ' ');
But what if the original sentence already contains the '&' character?
Say I would do the same thing with the sentence 'I am happy & healthy'. With the design above, the string would come back as 'I am happy healthy', since the '&' char has been replaced with a space.
(Of course, I could change the & character to a more unlikely symbol, such as ¤, but I want this to be bullet proof)
I used to know how to solve this, but I forgot how.
Any ideas?
Thanks!
Fredrik
Maybe you can use url encoding (percent encoding) as an inspiration.
Characters that are not valid in a url are escaped by writing %XX where XX is a numeric code that represents the character. The % sign itself can also be escaped in the same way, so that way you never run into problems when translating it back to the original string.
There are probably other similar encodings, and for your own application you can use an & just as well as a %, but by using an existing encoding like this, you can probably also find existing functions to do the encoding and decoding for you.