Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
eae6e97d
Commit
eae6e97d
authored
5 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
no-jira: update clean XML method to allow all range of unicodes
parent
bf63e8ee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/olat/core/util/StringHelper.java
+9
-8
9 additions, 8 deletions
src/main/java/org/olat/core/util/StringHelper.java
src/test/java/org/olat/core/util/StringHelperTest.java
+4
-0
4 additions, 0 deletions
src/test/java/org/olat/core/util/StringHelperTest.java
with
13 additions
and
8 deletions
src/main/java/org/olat/core/util/StringHelper.java
+
9
−
8
View file @
eae6e97d
...
@@ -488,23 +488,24 @@ public class StringHelper {
...
@@ -488,23 +488,24 @@ public class StringHelper {
if
(
string
==
null
)
return
null
;
if
(
string
==
null
)
return
null
;
if
(
string
.
length
()
==
0
)
return
string
;
if
(
string
.
length
()
==
0
)
return
string
;
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
(
string
.
length
()
);
char
[]
charArr
=
string
.
toCharArray
();
char
[]
charArr
=
string
.
toCharArray
();
int
numOfCharacters
=
charArr
.
length
;
int
numOfCharacters
=
charArr
.
length
;
for
(
int
i
=
0
;
i
<
numOfCharacters
;
i
++)
{
for
(
int
i
=
0
;
i
<
numOfCharacters
;
i
++)
{
char
ch
=
charArr
[
i
]
;
int
ch
=
string
.
codePointAt
(
i
)
;
if
(
ch
<
32
)
{
if
(
ch
<
32
)
{
switch
(
ch
)
{
switch
(
ch
)
{
case
'\n'
:
sb
.
append
(
ch
);
break
;
//0x000A
case
'\n'
:
//0x000A
case
'\t'
:
sb
.
append
(
ch
);
break
;
//0x0009
case
'\t'
:
//0x0009
case
'\r'
:
sb
.
append
(
ch
);
break
;
//0x000D
case
'\r'
:
sb
.
appendCodePoint
(
ch
);
break
;
//0x000D
default
:
// dump them
}
}
}
else
if
(
ch
>=
0x0020
&&
ch
<=
0xD7FF
)
{
}
else
if
(
ch
>=
0x0020
&&
ch
<=
0xD7FF
)
{
sb
.
append
(
ch
);
sb
.
append
CodePoint
(
ch
);
}
else
if
(
ch
>=
0xE000
&&
ch
<=
0xFFFD
)
{
}
else
if
(
ch
>=
0xE000
&&
ch
<=
0xFFFD
)
{
sb
.
append
(
ch
);
sb
.
append
CodePoint
(
ch
);
}
else
if
(
ch
>=
0x10000
&&
ch
<=
0x10FFFF
)
{
}
else
if
(
ch
>=
0x10000
&&
ch
<=
0x10FFFF
)
{
sb
.
append
(
ch
);
sb
.
append
CodePoint
(
ch
);
}
}
}
}
return
sb
.
toString
();
return
sb
.
toString
();
...
...
This diff is collapsed.
Click to expand it.
src/test/java/org/olat/core/util/StringHelperTest.java
+
4
−
0
View file @
eae6e97d
...
@@ -139,6 +139,10 @@ public class StringHelperTest {
...
@@ -139,6 +139,10 @@ public class StringHelperTest {
//it's pahlavi \u10B7x
//it's pahlavi \u10B7x
String
value12
=
StringHelper
.
cleanUTF8ForXml
(
"Hello\u10B7x pahlavi"
);
String
value12
=
StringHelper
.
cleanUTF8ForXml
(
"Hello\u10B7x pahlavi"
);
Assert
.
assertEquals
(
"Pahlavi test"
,
"Hello\u10B7x pahlavi"
,
value12
);
Assert
.
assertEquals
(
"Pahlavi test"
,
"Hello\u10B7x pahlavi"
,
value12
);
// smile
String
value13
=
StringHelper
.
cleanUTF8ForXml
(
"Smile \uD83D\uDE00x"
);
Assert
.
assertEquals
(
"Smile test"
,
"Smile \uD83D\uDE00x"
,
value13
);
}
}
@Test
@Test
...
...
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