@@ -258,7 +258,7 @@ void WriteAttribute(string name, Type type, object value, bool in_array)
258258 else if ( type == typeof ( float ) )
259259 value = FormattableString . Invariant ( $ "{ ( float ) value } ") ;
260260 else if ( type == typeof ( byte [ ] ) )
261- value = BitConverter . ToString ( ( byte [ ] ) value ) . Replace ( "-" , string . Empty , false , CultureInfo . InvariantCulture ) ;
261+ value = Convert . ToHexString ( ( byte [ ] ) value ) . Replace ( "-" , string . Empty , false , CultureInfo . InvariantCulture ) ;
262262 else if ( type == typeof ( TimeSpan ) )
263263 value = ( ( TimeSpan ) value ) . TotalSeconds . ToString ( CultureInfo . InvariantCulture ) ;
264264 else if ( type == typeof ( Color ) )
@@ -267,7 +267,7 @@ void WriteAttribute(string name, Type type, object value, bool in_array)
267267 value = FormattableString . Invariant ( $ "{ castValue . R } { castValue . G } { castValue . B } { castValue . A } ") ;
268268 }
269269 else if ( value is ulong ulong_value )
270- value = $ "0x{ ulong_value . ToString ( CultureInfo . InvariantCulture ) : X } ";
270+ value = $ "0x{ ulong_value . ToString ( "x" , CultureInfo . InvariantCulture ) } ";
271271 else if ( type == typeof ( Vector2 ) )
272272 {
273273 var castValue = ( Vector2 ) value ;
@@ -554,35 +554,35 @@ object Decode_ParseValue(Type type, string value)
554554 if ( type == typeof ( Element ) )
555555 return Decode_ParseElement ( value ) ;
556556 if ( type == typeof ( int ) )
557- return int . Parse ( value ) ;
557+ return int . Parse ( value , CultureInfo . InvariantCulture ) ;
558558 else if ( type == typeof ( float ) )
559- return float . Parse ( value ) ;
559+ return float . Parse ( value , CultureInfo . InvariantCulture ) ;
560560 else if ( type == typeof ( bool ) )
561- return byte . Parse ( value ) == 1 ;
561+ return byte . Parse ( value , CultureInfo . InvariantCulture ) == 1 ;
562562 else if ( type == typeof ( byte [ ] ) )
563563 {
564564 byte [ ] result = new byte [ value . Length / 2 ] ;
565565 for ( int i = 0 ; i * 2 < value . Length ; i ++ )
566566 {
567- result [ i ] = byte . Parse ( value . Substring ( i * 2 , 2 ) , System . Globalization . NumberStyles . HexNumber ) ;
567+ result [ i ] = byte . Parse ( value . AsSpan ( i * 2 , 2 ) , System . Globalization . NumberStyles . HexNumber , CultureInfo . InvariantCulture ) ;
568568 }
569569 return result ;
570570 }
571571 else if ( type == typeof ( TimeSpan ) )
572- return TimeSpan . FromTicks ( ( long ) ( double . Parse ( value ) * TimeSpan . TicksPerSecond ) ) ;
572+ return TimeSpan . FromTicks ( ( long ) ( double . Parse ( value , CultureInfo . InvariantCulture ) * TimeSpan . TicksPerSecond ) ) ;
573573
574574 var num_list = value . Split ( ( char [ ] ) null , StringSplitOptions . RemoveEmptyEntries ) ;
575575
576576 if ( type == typeof ( Color ) )
577577 {
578- var rgba = num_list . Select ( i => byte . Parse ( i ) ) . ToArray ( ) ;
578+ var rgba = num_list . Select ( i => byte . Parse ( i , CultureInfo . InvariantCulture ) ) . ToArray ( ) ;
579579 return Color . FromBytes ( rgba ) ;
580580 }
581581
582- if ( type == typeof ( ulong ) ) return ulong . Parse ( value . Remove ( 0 , 2 ) , System . Globalization . NumberStyles . HexNumber ) ;
583- if ( type == typeof ( byte ) ) return byte . Parse ( value ) ;
582+ if ( type == typeof ( ulong ) ) return ulong . Parse ( value . Remove ( 0 , 2 ) , System . Globalization . NumberStyles . HexNumber , CultureInfo . InvariantCulture ) ;
583+ if ( type == typeof ( byte ) ) return byte . Parse ( value , CultureInfo . InvariantCulture ) ;
584584
585- var f_list = num_list . Select ( i => float . Parse ( i ) ) . ToArray ( ) ;
585+ var f_list = num_list . Select ( i => float . Parse ( i , CultureInfo . InvariantCulture ) ) . ToArray ( ) ;
586586 if ( type == typeof ( Vector2 ) ) return new Vector2 ( f_list [ 0 ] , f_list [ 1 ] ) ;
587587 else if ( type == typeof ( Vector3 ) ) return new Vector3 ( f_list [ 0 ] , f_list [ 1 ] , f_list [ 2 ] ) ;
588588 else if ( type == typeof ( Vector4 ) ) return new Vector4 ( f_list [ 0 ] , f_list [ 1 ] , f_list [ 2 ] , f_list [ 3 ] ) ;
0 commit comments