Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository 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
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
6c9de877
Commit
6c9de877
authored
18 years ago
by
Regis Houssin
Browse files
Options
Downloads
Patches
Plain Diff
Ajout fonction qui vérifie si le flux rss est en utf8
parent
78756133
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/includes/boxes/box_external_rss.php
+30
-1
30 additions, 1 deletion
htdocs/includes/boxes/box_external_rss.php
with
30 additions
and
1 deletion
htdocs/includes/boxes/box_external_rss.php
+
30
−
1
View file @
6c9de877
...
...
@@ -91,7 +91,15 @@ class box_external_rss extends ModeleBoxes {
{
$item
=
$rss
->
items
[
$i
];
$href
=
$item
[
'link'
];
$title
=
utf8_decode
(
urldecode
(
$item
[
'title'
]));
$result
=
$this
->
utf8_check
(
urldecode
(
$item
[
'title'
]));
if
(
$result
)
{
$title
=
utf8_decode
(
urldecode
(
$item
[
'title'
]));
}
else
{
$title
=
(
urldecode
(
$item
[
'title'
]));
}
$title
=
ereg_replace
(
"([[:alnum:]])\?([[:alnum:]])"
,
"
\\
1'
\\
2"
,
$title
);
// Gre problme des apostrophes mal code/dcode par utf8
$title
=
ereg_replace
(
"^\s+"
,
""
,
$title
);
// Supprime espaces de dbut
$this
->
info_box_contents
[
"
$href
"
]
=
"
$title
"
;
...
...
@@ -102,6 +110,27 @@ class box_external_rss extends ModeleBoxes {
'target'
=>
'newrss'
);
}
}
/**
* \brief Vrifie si le flux est en UTF8
* \param $Str chaine vrifier
*/
function
utf8_check
(
$Str
)
{
for
(
$i
=
0
;
$i
<
strlen
(
$Str
);
$i
++
)
{
if
(
ord
(
$Str
[
$i
])
<
0x80
)
continue
;
# 0bbbbbbb
elseif
((
ord
(
$Str
[
$i
])
&
0xE0
)
==
0xC0
)
$n
=
1
;
# 110bbbbb
elseif
((
ord
(
$Str
[
$i
])
&
0xF0
)
==
0xE0
)
$n
=
2
;
# 1110bbbb
elseif
((
ord
(
$Str
[
$i
])
&
0xF8
)
==
0xF0
)
$n
=
3
;
# 11110bbb
elseif
((
ord
(
$Str
[
$i
])
&
0xFC
)
==
0xF8
)
$n
=
4
;
# 111110bb
elseif
((
ord
(
$Str
[
$i
])
&
0xFE
)
==
0xFC
)
$n
=
5
;
# 1111110b
else
return
false
;
# Does not match any model
for
(
$j
=
0
;
$j
<
$n
;
$j
++
)
{
# n bytes matching 10bbbbbb follow ?
if
((
++
$i
==
strlen
(
$Str
))
||
((
ord
(
$Str
[
$i
])
&
0xC0
)
!=
0x80
))
return
false
;
}
}
return
true
;
}
function
showBox
()
{
...
...
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