Special characters throwing off str_pad in php?

前端 未结 3 832
半阙折子戏
半阙折子戏 2020-12-16 19:26

I\'m writing a module that is supposed to be able to export transaction records in BankOne format.

Here is the specification of the format

Here is an example

3条回答
  •  感情败类
    2020-12-16 20:23

    This is happening because 'Ã' is a multi-byte character (4 bytes long), and str_pad is counting bytes rather than logical characters.

    This is why you are missing three spaces, str_pad is counting 'Ã' as 4 single byte characters instead of one multi-byte one.

    Try this function (credit here).

    
    

提交回复
热议问题