Heavy quark fragmentation into heavy mesons