Profile: fix heap snapshot is valid char check (#53984)
Followup to https://github.com/JuliaLang/julia/pull/53833
Fixes a failure seen in https://github.com/JuliaLang/julia/pull/53974
(below)
I believe this is the more correct check to make?
The heapsnapshot generated from this PR is viewable in vscode.
```
2024-04-06 09:33:58 EDT From worker 7: ERROR: Base.InvalidCharError{Char}('\xc1\xae')
2024-04-06 09:33:58 EDT From worker 7: Stacktrace:
2024-04-06 09:33:58 EDT From worker 7: [1] throw_invalid_char(c::Char)
2024-04-06 09:33:58 EDT From worker 7: @ Base ./char.jl:86
2024-04-06 09:33:58 EDT From worker 7: [2] UInt32
2024-04-06 09:33:58 EDT From worker 7: @ ./char.jl:133 [inlined]
2024-04-06 09:33:58 EDT From worker 7: [3] category_code
2024-04-06 09:33:58 EDT From worker 7: @ ./strings/unicode.jl:339 [inlined]
2024-04-06 09:33:58 EDT From worker 7: [4] isassigned
2024-04-06 09:33:58 EDT From worker 7: @ ./strings/unicode.jl:355 [inlined]
2024-04-06 09:33:58 EDT From worker 7: [5] isassigned
2024-04-06 09:33:58 EDT From worker 7: @ /cache/build/tester-amdci5-14/julialang/julia-master/julia-41d026beaf/share/julia/stdlib/v1.12/Unicode/src/Unicode.jl:138 [inlined]
2024-04-06 09:33:58 EDT From worker 7: [6] print_str_escape_json(stream::IOStream, s::String)
2024-04-06 09:33:58 EDT From worker 7: @ Profile.HeapSnapshot /cache/build/tester-amdci5-14/julialang/julia-master/julia-41d026beaf/share/julia/stdlib/v1.12/Profile/src/heapsnapshot_reassemble.jl:239
2024-04-06 09:33:59 EDT From worker 7: [7] (::Profile.HeapSnapshot.var"#5#6"{IOStream})(strings_io::IOStream)
2024-04-06 09:33:59 EDT From worker 7: @ Profile.HeapSnapshot /cache/build/tester-amdci5-14/julialang/julia-master/julia-41d026beaf/share/julia/stdlib/v1.12/Profile/src/heapsnapshot_reassemble.jl:192
```