A bug of build-in function Char?
显示 更早的评论
Well, I have a double array readed from a binary file, such as X=[66 43 22 0 67],
When I convert the array into string, char(X), the ans is 'B+! C'
I think that the function Char() should take [0] as the ending of a string, why it treat zero also as a part of string?
采纳的回答
更多回答(2 个)
Walter Roberson
2012-12-21
sprintf('%s', char(X))
sprintf() has an undocumented effect (some would say it is a bug) of ending at the first binary 0.
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!