Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ESP32-audioI2S
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ESP32-audioI2S
Commits
8d50fd3b
Commit
8d50fd3b
authored
May 04, 2024
by
schreibfaul1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
latinToUTF8 wrong buffLength
and not convert range 0xD0...0xDF char "ß"
parent
1d9b299d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
49 deletions
+28
-49
src/Audio.cpp
src/Audio.cpp
+26
-47
src/Audio.h
src/Audio.h
+2
-2
No files found.
src/Audio.cpp
View file @
8d50fd3b
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
*
*
* Created on: Oct 26.2018
* Created on: Oct 26.2018
*
*
* Version 3.0.9
j
* Version 3.0.9
k
* Updated on:
Apr 28
.2024
* Updated on:
May 04
.2024
* Author: Wolle (schreibfaul1)
* Author: Wolle (schreibfaul1)
*
*
*/
*/
...
@@ -1163,56 +1163,35 @@ bool Audio::latinToUTF8(char* buff, size_t bufflen) {
...
@@ -1163,56 +1163,35 @@ bool Audio::latinToUTF8(char* buff, size_t bufflen) {
// converted to UTF-8. If UTF-8 is already present, nothing is done and true is returned.
// converted to UTF-8. If UTF-8 is already present, nothing is done and true is returned.
// A conversion to UTF-8 extends the string. Therefore it is necessary to know the buffer size. If the converted
// A conversion to UTF-8 extends the string. Therefore it is necessary to know the buffer size. If the converted
// string does not fit into the buffer, false is returned
// string does not fit into the buffer, false is returned
// utf8 bytelength: >=0xF0 3 bytes, >=0xE0 2 bytes, >=0xC0 1 byte, e.g. e293ab is ⓫
uint16_t
pos
=
0
;
uint16_t
in
=
0
;
uint8_t
ext_bytes
=
0
;
uint16_t
out
=
0
;
uint16_t
len
=
strlen
(
buff
);
uint8_t
c
;
while
(
pos
<
len
-
2
)
{
c
=
buff
[
pos
];
if
(
c
>=
0xC2
)
{
// is UTF8 char
pos
++
;
if
(
c
>=
0xC0
&&
buff
[
pos
]
<
0x80
)
{
ext_bytes
++
;
pos
++
;
}
if
(
c
>=
0xE0
&&
buff
[
pos
]
<
0x80
)
{
ext_bytes
++
;
pos
++
;
}
if
(
c
>=
0xF0
&&
buff
[
pos
]
<
0x80
)
{
ext_bytes
++
;
pos
++
;
}
}
else
pos
++
;
}
if
(
!
ext_bytes
)
return
true
;
// is UTF-8, do nothing
pos
=
0
;
char
*
iso8859_1
=
x_strdup
(
buff
)
;
while
(
buff
[
pos
]
!=
0
)
{
while
(
iso8859_1
[
in
]
!=
'\0'
){
if
((
buff
[
pos
]
&
0x80
)
==
0
)
{
if
(
iso8859_1
[
in
]
<
0x80
){
pos
++
;
buff
[
out
]
=
iso8859_1
[
in
];
continue
;
out
++
;
}
in
++
;
else
{
if
(
out
>
bufflen
)
goto
exit
;
len
=
strlen
(
buff
);
for
(
int
i
=
len
+
1
;
i
>
pos
;
i
--
)
{
buff
[
i
+
1
]
=
buff
[
i
];
}
uint8_t
c
=
buff
[
pos
];
buff
[
pos
]
=
0xc0
|
((
c
>>
6
)
&
0x1f
);
// 2+1+5 bits
pos
++
;
buff
[
pos
]
=
0x80
|
((
char
)
c
&
0x3f
);
// 1+1+6 bits
}
}
pos
++
;
else
{
if
(
pos
>
bufflen
-
3
)
{
buff
[
out
]
=
(
0xC0
|
iso8859_1
[
in
]
>>
6
);
buff
[
bufflen
-
1
]
=
'\0'
;
out
++
;
return
false
;
// do not overwrite
if
(
out
+
1
>
bufflen
)
goto
exit
;
buff
[
out
]
=
(
0x80
|
(
iso8859_1
[
in
]
&
0x3F
));
out
++
;
in
++
;
}
}
}
}
buff
[
out
]
=
'\0'
;
if
(
iso8859_1
)
{
free
(
iso8859_1
);
iso8859_1
=
NULL
;}
return
true
;
return
true
;
exit:
if
(
iso8859_1
)
{
free
(
iso8859_1
);
iso8859_1
=
NULL
;}
return
false
;
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
size_t
Audio
::
readAudioHeader
(
uint32_t
bytes
)
{
size_t
Audio
::
readAudioHeader
(
uint32_t
bytes
)
{
...
@@ -1800,7 +1779,7 @@ int Audio::read_ID3_Header(uint8_t* data, size_t len) {
...
@@ -1800,7 +1779,7 @@ int Audio::read_ID3_Header(uint8_t* data, size_t len) {
j
++
;
j
++
;
}
}
m_ibuff
[
k
]
=
'\0'
;
// new termination
m_ibuff
[
k
]
=
'\0'
;
// new termination
latinToUTF8
(
m_ibuff
,
k
-
1
);
latinToUTF8
(
m_ibuff
,
m_ibuffSize
);
}
}
showID3Tag
(
tag
,
m_ibuff
);
showID3Tag
(
tag
,
m_ibuff
);
return
fs
;
return
fs
;
...
...
src/Audio.h
View file @
8d50fd3b
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
*
*
* Created on: Oct 28,2018
* Created on: Oct 28,2018
*
*
* Version 3.0.9
j
* Version 3.0.9
k
* Updated on:
Apr 28
.2024
* Updated on:
May 04
.2024
* Author: Wolle (schreibfaul1)
* Author: Wolle (schreibfaul1)
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment