Пример #1
0
size_t io::writeUnicodeText(ID3_Writer& writer, String data, bool bom)
{
  ID3_Writer::pos_type beg = writer.getCur();
  size_t size = (data.size() / 2) * 2;
  if (size == 0)
  {
    return 0;
  }
  if (bom)
  {
    // Write the BOM: 0xFEFF
    unicode_t BOM = 0xFEFF;
    writer.writeChars((const unsigned char*) &BOM, 2);
  }
  // AF outside if( bom )

    for (size_t i = 0; i < size; i += 2)
    {
    // AF TODO FIXME PATCH      unicode_t ch = (data[i] << 8) | data[i+1];
        // AF: SWAP BYTES AND PERFORM unsigned char cast
        unicode_t ch = (static_cast<unsigned char>(data[i+1]) << 8) | static_cast<unsigned char>(data[i]);
        writer.writeChars((const unsigned char*) &ch, 2);
    }

    return writer.getCur() - beg;
}
size_t io::writeUnicodeText(ID3_Writer& writer, String data, bool bom)
{
  ID3_Writer::pos_type beg = writer.getCur();
  size_t size = (data.size() / 2) * 2;
  if (size == 0)
  {
    return 0;
  }
  int is_bom = isBOM(data[0],data[1]);
  if (!is_bom && bom) {
    // Write the BOM: 0xFEFF
    const unsigned char BOMch1 = 0xFE;
    const unsigned char BOMch2 = 0xFF;
    writer.writeChars(&BOMch1, 1);
    writer.writeChars(&BOMch2, 1);
  }
  for (size_t i = 0; i < size; i += 2)
  {
    if (!i && !bom && is_bom) {
      // Skip unneeded leading BOM
      continue;
    }
    if (is_bom >= 0) {
      writer.writeChars(data.data()+i, 1);
      writer.writeChars(data.data()+i+1, 1);
    }
    else {
      writer.writeChars(data.data()+i+1, 1);
      writer.writeChars(data.data()+i, 1);
    }
  }
  return writer.getCur() - beg;
}
size_t io::writeTrailingSpaces(ID3_Writer& writer, String buf, size_t len)
{
  ID3_Writer::pos_type beg = writer.getCur();
  ID3_Writer::size_type strLen = buf.size();
  ID3_Writer::size_type size = min((unsigned int)len, (unsigned int)strLen);
  writer.writeChars(buf.data(), size);
  for (; size < len; ++size)
  {
    writer.writeChar('\0');
  }
  return writer.getCur() - beg;
}
Пример #4
0
Файл: tag.cpp Проект: e1z0/sMule
size_t ID3_Tag::Render(ID3_Writer& writer, ID3_TagType tt) const
{
  ID3_Writer::pos_type beg = writer.getCur();
  if (ID3TT_ID3V2 & tt)
  {
    id3::v2::render(writer, *this);
  }
  else if (ID3TT_ID3V1 & tt)
  {
    id3::v1::render(writer, *this);
  }
  return writer.getCur() - beg;
}
Пример #5
0
size_t io::writeUnicodeText(ID3_Writer& writer, String data, bool bom)
{
  ID3_Writer::pos_type beg = writer.getCur();
  size_t size = (data.size() / 2) * 2;
  if (size == 0)
  {
    return 0;
  }
  if (bom)
  {
    // Write the BOM: 0xFEFF
    unicode_t BOM = 0xFEFF;
    writer.writeChars((const unsigned char*) &BOM, 2);
  }
  writer.writeChars(&data[0], size);
  return writer.getCur() - beg;
}
Пример #6
0
size_t io::writeUnicodeText(ID3_Writer& writer, String data, bool bom)
{
  ID3_Writer::pos_type beg = writer.getCur();
  size_t size = (data.size() / 2) * 2;
  if (size == 0)
  {
    return 0;
  }
  if (bom)
  {
    // Write the BOM: 0xFEFF
    unicode_t BOM = 0xFEFF;
    writer.writeChars((const unsigned char*) &BOM, 2);
    for (size_t i = 0; i < size; i += 2)
    {
      unicode_t ch = (data[i] << 8) | data[i+1];
      writer.writeChars((const unsigned char*) &ch, 2);
    }
  }
  return writer.getCur() - beg;
}
size_t io::writeText(ID3_Writer& writer, String data)
{
  ID3_Writer::pos_type beg = writer.getCur();
  writer.writeChars(data.data(), data.size());
  return writer.getCur() - beg;
}