2018-08-03 Fred Gleason <fredg@paravelsystems.com>

* Fixed bugs in 'RDWaveFile' that caused corruption of UTF-8
	strings in RDXL chunks.
This commit is contained in:
Fred Gleason 2018-08-03 15:21:39 -04:00
parent 76b4c866eb
commit 6b1a06a910
3 changed files with 13 additions and 9 deletions

View File

@ -17318,3 +17318,6 @@
* Fixed a regression in 'RDAudioExport' that caused a segfault.
2018-08-03 Fred Gleason <fredg@paravelsystems.com>
* Fixed a regression in 'RDCart' that threw a SQL error.
2018-08-03 Fred Gleason <fredg@paravelsystems.com>
* Fixed bugs in 'RDWaveFile' that caused corruption of UTF-8
strings in RDXL chunks.

View File

@ -2478,17 +2478,16 @@ void RDWaveFile::WriteChunk(int fd,const char *cname,unsigned char *buf,
void RDWaveFile::WriteChunk(int fd,const char *cname,const QString &contents)
{
syslog(LOG_NOTICE,"writing %s: %d",cname,contents.length());
unsigned char size_buf[4];
size_buf[0]=contents.length()&0xff;
size_buf[1]=(contents.length()>>8)&0xff;
size_buf[2]=(contents.length()>>16)&0xff;
size_buf[3]=(contents.length()>>24)&0xff;
size_buf[0]=contents.utf8().length()&0xff;
size_buf[1]=(contents.utf8().length()>>8)&0xff;
size_buf[2]=(contents.utf8().length()>>16)&0xff;
size_buf[3]=(contents.utf8().length()>>24)&0xff;
lseek(fd,0,SEEK_END);
write(fd,cname,4);
write(fd,size_buf,4);
write(fd,contents,contents.length());
write(fd,contents.utf8(),contents.utf8().length());
}
@ -3091,7 +3090,7 @@ bool RDWaveFile::GetRdxl(int fd)
chunk=new char[chunk_size+1];
memset(chunk,0,chunk_size+1);
read(fd,chunk,chunk_size);
rdxl_contents=QString(chunk);
rdxl_contents=QString::fromUtf8(chunk);
delete chunk;
if(wave_data!=NULL) {

View File

@ -1130,12 +1130,14 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
if(import_string_title.isNull()) {
printf(" Importing file \"%s\" [%s] to cart %06u ... ",
(const char *)RDGetBasePart(filename).utf8(),
(const char *)wavedata->title().stripWhiteSpace(),*cartnum);
(const char *)wavedata->title().stripWhiteSpace().utf8(),
*cartnum);
}
else {
printf(" Importing file \"%s\" [%s] to cart %06u ... ",
(const char *)RDGetBasePart(filename).utf8(),
(const char *)import_string_title.stripWhiteSpace(),*cartnum);
(const char *)import_string_title.stripWhiteSpace().utf8(),
*cartnum);
}
}
fflush(stdout);