Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
12968fb6
Commit
12968fb6
authored
10 years ago
by
Andrew Scheller
Browse files
Options
Downloads
Patches
Plain Diff
Display \r and \t escape codes in string repr
parent
72d70cb0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/objstr.c
+4
-1
4 additions, 1 deletion
py/objstr.c
tests/basics/string-repr.py
+3
-0
3 additions, 0 deletions
tests/basics/string-repr.py
with
7 additions
and
1 deletion
py/objstr.c
+
4
−
1
View file @
12968fb6
...
...
@@ -63,7 +63,10 @@ void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *e
print
(
env
,
"%c"
,
*
s
);
}
else
if
(
*
s
==
'\n'
)
{
print
(
env
,
"
\\
n"
);
// TODO add more escape codes here if we want to match CPython
}
else
if
(
*
s
==
'\r'
)
{
print
(
env
,
"
\\
r"
);
}
else
if
(
*
s
==
'\t'
)
{
print
(
env
,
"
\\
t"
);
}
else
{
print
(
env
,
"
\\
x%02x"
,
*
s
);
}
...
...
This diff is collapsed.
Click to expand it.
tests/basics/string-repr.py
0 → 100644
+
3
−
0
View file @
12968fb6
# anything above 0xa0 is printed as Unicode by CPython3.3
for
c
in
range
(
0xa1
):
print
(
"
0x%02x: %s
"
%
(
c
,
repr
(
chr
(
c
))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment