From your description, "I need store the device name during scaning", I hope you are reading the device name from the ADV packets from the peripheral. Am I correct?
If then, from the adv packet itself you can get the length of the name. See the ADV packet structure in the attached ppt.
ADVERTISING DATA FORMAT.pptx 51.4 K