How can I say a file is SVG without using a magic number?

前端 未结 2 1714
伪装坚强ぢ
伪装坚强ぢ 2021-02-20 08:22

An SVG file is basically an XML file so I could use the string (or the hex representation: \'3c 3f 78 6d 6c\') as a

2条回答
  •  旧时难觅i
    2021-02-20 09:04

    You could try reading the beginning of the file as binary - if you can't find any magic numbers, you read it as a text file and match to any textual patterns you wish. Or vice-versa.

提交回复
热议问题