title_body: Is the length (in characters) of a token policy id always the same?
upvoted_answer: The policyId is the hash of the policy script. It is a blake2b-224 hash resulting in 28 bytes and a hex length of 56 chars. So, your code will always work and is the right way to do it.
  Find the spec defining the scriptHash here, note that the scriptHash is of type hash28 denoting the hash length.
  Also, the assetName can be of any length between 0-32 bytes. Something to keep a note of in your application, this also means that there can be a token without assetName. Find the assetName length spec here