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
Hide 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 @@
*
* Created on: Oct 26.2018
*
* Version 3.0.9
j
* Updated on:
Apr 28
.2024
* Version 3.0.9
k
* Updated on:
May 04
.2024
* Author: Wolle (schreibfaul1)
*
*/
...
...
@@ -1073,7 +1073,7 @@ void Audio::showID3Tag(const char* tag, const char* value) {
if
(
!
strcmp
(
tag
,
"TSSE"
))
sprintf
(
m_chbuf
,
"SettingsForEncoding: %s"
,
value
);
if
(
!
strcmp
(
tag
,
"TRDA"
))
sprintf
(
m_chbuf
,
"RecordingDates: %s"
,
value
);
if
(
!
m_f_m3u8data
)
if
(
!
strcmp
(
tag
,
"TXXX"
))
sprintf
(
m_chbuf
,
"UserDefinedText: %s"
,
value
);
if
(
!
strcmp
(
tag
,
"TXXX"
))
sprintf
(
m_chbuf
,
"UserDefinedText: %s"
,
value
);
if
(
!
strcmp
(
tag
,
"TYER"
))
sprintf
(
m_chbuf
,
"Year: %s"
,
value
);
if
(
!
strcmp
(
tag
,
"USER"
))
sprintf
(
m_chbuf
,
"TermsOfUse: %s"
,
value
);
if
(
!
strcmp
(
tag
,
"USLT"
))
sprintf
(
m_chbuf
,
"Lyrics: %s"
,
value
);
...
...
@@ -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.
// 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
// utf8 bytelength: >=0xF0 3 bytes, >=0xE0 2 bytes, >=0xC0 1 byte, e.g. e293ab is ⓫
uint16_t
pos
=
0
;
uint8_t
ext_bytes
=
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
uint16_t
in
=
0
;
uint16_t
out
=
0
;
pos
=
0
;
char
*
iso8859_1
=
x_strdup
(
buff
)
;
while
(
buff
[
pos
]
!=
0
)
{
if
((
buff
[
pos
]
&
0x80
)
==
0
)
{
pos
++
;
continue
;
}
else
{
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
while
(
iso8859_1
[
in
]
!=
'\0'
){
if
(
iso8859_1
[
in
]
<
0x80
){
buff
[
out
]
=
iso8859_1
[
in
];
out
++
;
in
++
;
if
(
out
>
bufflen
)
goto
exit
;
}
pos
++
;
if
(
pos
>
bufflen
-
3
)
{
buff
[
bufflen
-
1
]
=
'\0'
;
return
false
;
// do not overwrite
else
{
buff
[
out
]
=
(
0xC0
|
iso8859_1
[
in
]
>>
6
);
out
++
;
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
;
exit:
if
(
iso8859_1
)
{
free
(
iso8859_1
);
iso8859_1
=
NULL
;}
return
false
;
}
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
size_t
Audio
::
readAudioHeader
(
uint32_t
bytes
)
{
...
...
@@ -1800,7 +1779,7 @@ int Audio::read_ID3_Header(uint8_t* data, size_t len) {
j
++
;
}
m_ibuff
[
k
]
=
'\0'
;
// new termination
latinToUTF8
(
m_ibuff
,
k
-
1
);
latinToUTF8
(
m_ibuff
,
m_ibuffSize
);
}
showID3Tag
(
tag
,
m_ibuff
);
return
fs
;
...
...
src/Audio.h
View file @
8d50fd3b
...
...
@@ -3,8 +3,8 @@
*
* Created on: Oct 28,2018
*
* Version 3.0.9
j
* Updated on:
Apr 28
.2024
* Version 3.0.9
k
* Updated on:
May 04
.2024
* 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