if I encode the following text
str = 'Hello\nWorld';
enc = urlencode(str)
I get this output that is wrong:
enc =
'Hello%5CnWorld'
instead of this one that would be the correct one:
enc =
'Hello%0AWorld'
Is it possible to change the behavior so that '\n' is converted into '%0A' instead of '%5Cn'?

 채택된 답변

Steven Lord
Steven Lord 2022년 1월 3일

0 개 추천

s1 = 'Hello\nWorld'
s1 = 'Hello\nWorld'
s1E = urlencode(s1)
s1E = 'Hello%5CnWorld'
s2 = sprintf('Hello\nWorld')
s2 =
'Hello World'
s2E = urlencode(s2)
s2E = 'Hello%0AWorld'
whos
Name Size Bytes Class Attributes s1 1x12 24 char s1E 1x14 28 char s2 1x11 22 char s2E 1x13 26 char
s1 contains 12 characters including both \ and n while s2 contains 11 including a newline. Just because text includes the pair of characters '\n' doesn't mean that's treated as a newline.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Arduino Hardware에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2022년 1월 3일

답변:

2022년 1월 3일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by