回答編集履歴

4

調整

2024/05/21 07:39

投稿

yambejp
yambejp

スコア117615

test CHANGED
@@ -11,7 +11,8 @@
11
11
  $encodings = [
12
12
  "ASCII",
13
13
  "SJIS-win",
14
- "UTF-8"
14
+ "UTF-8",
15
+ "cp51932,
15
16
  ];
16
17
  $encoding=mb_detect_encoding($entities,$encodings);
17
18
  $str= mb_encode_numericentity( $entities, array( 0x0, 0xffff, 0, 0xffff ), $encoding ) ;

3

調整

2024/05/21 07:33

投稿

yambejp
yambejp

スコア117615

test CHANGED
@@ -3,14 +3,18 @@
3
3
  であれば「UTF-8」を指定すればいいだけでは?
4
4
 
5
5
  # 参考
6
-
6
+ ※調整
7
7
  ```php
8
- <?PHP
9
8
  $entities=<<<eof
10
9
  <hoge>てすと髙<fuga>
11
10
  eof;
11
+ $encodings = [
12
+ "ASCII",
13
+ "SJIS-win",
14
+ "UTF-8"
15
+ ];
12
- $encoding='SJIS-win';//元のエンコードに合わせる(UTF-8)
16
+ $encoding=mb_detect_encoding($entities,$encodings);
13
- $str= mb_encode_numericentity( $entities, array( 0x0, 0xffff, 0, 0xffff ), $encoding) ;
17
+ $str= mb_encode_numericentity( $entities, array( 0x0, 0xffff, 0, 0xffff ), $encoding ) ;
14
18
  print <<<eof
15
19
  <textarea rows="4" cols="50">
16
20
  $str

2

調整

2024/05/21 05:01

投稿

yambejp
yambejp

スコア117615

test CHANGED
@@ -5,5 +5,15 @@
5
5
  # 参考
6
6
 
7
7
  ```php
8
+ <?PHP
9
+ $entities=<<<eof
10
+ <hoge>てすと髙<fuga>
11
+ eof;
12
+ $encoding='SJIS-win';//元のエンコードに合わせる(UTF-8)
8
- mb_encode_numericentity($_SESSION['filename'], array( 0x0, 0xffff, 0, 0xffff ), 'UTF-8' )
13
+ $str= mb_encode_numericentity( $entities, array( 0x0, 0xffff, 0, 0xffff ), $encoding) ;
14
+ print <<<eof
15
+ <textarea rows="4" cols="50">
16
+ $str
17
+ </textarea>
18
+ eof;
9
19
  ```

1

調整

2024/05/21 04:27

投稿

yambejp
yambejp

スコア117615

test CHANGED
@@ -1,3 +1,9 @@
1
1
  > UTF-8だと上手くいきますが、SJIS-winだとデータが抽出できない
2
2
 
3
3
  であれば「UTF-8」を指定すればいいだけでは?
4
+
5
+ # 参考
6
+
7
+ ```php
8
+ mb_encode_numericentity($_SESSION['filename'], array( 0x0, 0xffff, 0, 0xffff ), 'UTF-8' )
9
+ ```