|
3 | 3 | * |
4 | 4 | * Created on: Oct 26.2018 |
5 | 5 | * |
6 | | - * Version 3.0.7 |
7 | | - * Updated on: Oct 08.2023 |
| 6 | + * Version 3.0.7a |
| 7 | + * Updated on: Nov 11.2023 |
8 | 8 | * Author: Wolle (schreibfaul1) |
9 | 9 | * |
10 | 10 | */ |
@@ -1042,14 +1042,16 @@ bool Audio::latinToUTF8(char* buff, size_t bufflen){ |
1042 | 1042 | pos = 0; |
1043 | 1043 |
|
1044 | 1044 | while(buff[pos] != 0){ |
1045 | | - len = strlen(buff); |
1046 | | - if(buff[pos] >= 0x80 && buff[pos+1] < 0x80){ // is not UTF8, is latin? |
1047 | | - for(int i = len+1; i > pos; i--){ |
| 1045 | + if ((buff[pos] & 0x80) == 0) {pos++; continue;} |
| 1046 | + else{ |
| 1047 | + len = strlen(buff); |
| 1048 | + for(int i = len + 1; i > pos; i--){ |
1048 | 1049 | buff[i+1] = buff[i]; |
1049 | 1050 | } |
1050 | 1051 | uint8_t c = buff[pos]; |
1051 | | - buff[pos++] = 0xc0 | ((c >> 6) & 0x1f); // 2+1+5 bits |
1052 | | - buff[pos++] = 0x80 | ((char)c & 0x3f); // 1+1+6 bits |
| 1052 | + buff[pos] = 0xc0 | ((c >> 6)& 0x1f); // 2+1+5 bits |
| 1053 | + pos++; |
| 1054 | + buff[pos] = 0x80 | ((char)c & 0x3f); // 1+1+6 bits |
1053 | 1055 | } |
1054 | 1056 | pos++; |
1055 | 1057 | if(pos > bufflen -3){ |
@@ -1640,17 +1642,15 @@ int Audio::read_ID3_Header(uint8_t *data, size_t len) { |
1640 | 1642 |
|
1641 | 1643 | if(!isUnicode){ |
1642 | 1644 | uint16_t j = 0, k = 0; |
1643 | | - j = 0; |
1644 | | - k = 0; |
1645 | 1645 | while(j < fs) { |
1646 | | - if(m_ibuff[j] == 0x0A) m_ibuff[j] = 0x20; // replace LF by space |
1647 | 1646 | if(m_ibuff[j] > 0x1F) { |
1648 | | - m_ibuff[k] = m_ibuff[j]; |
| 1647 | + m_ibuff[k] = m_ibuff[j]; //remove non printables |
1649 | 1648 | k++; |
1650 | 1649 | } |
1651 | 1650 | j++; |
1652 | | - } //remove non printables |
1653 | | - if(k>0) m_ibuff[k] = 0; else m_ibuff[0] = 0; // new termination |
| 1651 | + } |
| 1652 | + m_ibuff[k] = '\0'; // new termination |
| 1653 | + latinToUTF8(m_ibuff, k - 1); |
1654 | 1654 | } |
1655 | 1655 | showID3Tag(tag, m_ibuff); |
1656 | 1656 | return fs; |
|
0 commit comments